|
From: Juliet <no...@li...> - 2001-10-05 16:54:14
|
At 18.38 15/09/2001 -0400, you wrote: > This is my first post to this list. My name is Joseph, you can call > me Blumojo (or "blu" or "mojo" for short). Welcome, mojo :) hope you enjoy your stay >I really like Dev-cpp and am thinking of sending a donation if I can get >the following to work. I am working on NeHe's OpenGL tutorials >(<http://nehe.gamedev.net/>http://nehe.gamedev.net/) which are really >good - even for a novice like me, but the code he gave was for Visual >CPP. I have worked through a couple of the problems, but have become >"stumped" on lesson 7 where the compiler has given me: >"implicit declaration of function int free()" C calling convention permits functions with an arbitrary number of parameters, since the parameters push AND pop is done on the caller side. Thus C code doesn't need prototypes for functions defined before they're called in the code. This is fine as long as you don't pass parameters of the wrong type (and if it happens the compiler won't warn you because of the lack of a prototype, you'll discover eventual type mismatches at runtime), and as long as you use the cdecl calling convention, that mangles function names by simply putting a "_" in front of them. Things can go ugly with stdcall convention, it mangles names as "_functionname@stacksize", so if you don't provide a prototype the compiler won't be able to generate the "@stacksize" part, the name will not match, the linking phase will fail, thanks for playing, game over. In short, you (they) forgot to include the file where free() is defined (try stdlib.h or malloc.h) AFAIK, malloc() and free() can be safely considered the best ways to allocate/free memory. On Windows, if you wish, you can use LocalAlloc/LocalFree, they map directly on malloc/free but providing for much more flexibility (initialization with zeros, moveable memory blocks, you can retrieve at any time the size of the buffer through its pointer, etc.), or HeapAlloc/HeapFree to allocate a bare block of heap (dangerous!), HeapCreate to create other heaps than the one allocated by default, or the powerful Virtual* family of functions if you're crazy enough to try to implement your own malloc/free. But, you see, these are very platform-dependent choices. You should be fine with the standard memory management |