1. Use of sizeof()

Hi

Is there any way of using sizeof() from Euphoria. I wish to find the size of a structure created by a lib, but I don't know which dll/so to open. (also I want to find the size of a bitmap or image in memory, but first step is to experiment with sizeof())

Also, if I was going to use other C functions, what reference material would I use to find out for myself which dll/so to open (eg malloc)

Chris

new topic     » topic index » view message » categorize

2. Re: Use of sizeof()

ChrisB said...

Hi

Is there any way of using sizeof() from Euphoria.

Sorry, no. sizeof() is an *operator*, not a function (or even a macro). So it only exists at compile time and is evaluated by the compiler.

ChrisB said...

I wish to find the size of a structure created by a lib, but I don't know which dll/so to open. (also I want to find the size of a bitmap or image in memory, but first step is to experiment with sizeof())

Normally, you'd consult that library's documentation to learn this. However, in the specific case of structures, there is nothing exported by the dll. This information is going to be in a header file (the library's documentation should tell you which header file), and you will need to transcribe it from the C into Eu.

ChrisB said...

Also, if I was going to use other C functions, what reference material would I use to find out for myself which dll/so to open (eg malloc)

Chris

On Linux, normally just using a man page is enough. My version of man page for malloc() doesn't state which library to use however, but in this case it is /lib/libc.so.6

There are also man pages online (as HTML), e.g. http://linux.die.net/man/3/malloc

On Windows, MSDN (msdn.microsoft.com) is the source to hit. e.g. http://msdn.microsoft.com/en-us/library/ms687404(VS.85).aspx

new topic     » goto parent     » topic index » view message » categorize

3. Re: Use of sizeof()

jimcbrown said...

On Linux, normally just using a man page is enough. My version of man page for malloc() doesn't state which library to use however, but in this case it is /lib/libc.so.6

Yeah, that usually means that it's part of the C runtime library (or maybe even more basic). When using euphoria, this means that you can simply use the result of open_dll("") in the define_c calls. Linux allows you to automatically link to things like that which are already linked (and you're pretty much guaranteed to be linked to the C runtime library--and definitely so when using euphoria).

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: Use of sizeof()

thanks

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu