1. Use of sizeof()
- Posted by ChrisB (moderator) Oct 27, 2009
- 1228 views
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
2. Re: Use of sizeof()
- Posted by jimcbrown (admin) Oct 27, 2009
- 1279 views
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.
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.
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
3. Re: Use of sizeof()
- Posted by mattlewis (admin) Oct 27, 2009
- 1240 views
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