: thus on Mon, 22 Dec 1997 01:30:06 -0600, Akuma/Chris virtually wrote: > Ok, I've got a few things on my mind before I go to sleep tonite > (it's 1:19 am). > first of all. > I see in many places the > #if(n)def __SOMETHING_C__ > and i also see > #if (!)defined(__SOMETHING_C__) > i was wondering if there is a real (codewise) difference or if the > only difference is that one is a GNU C extension and the other isn't. > b/c if this is true, i may as well keep it the way i've been doing it > (#ifdef) The #ifdef's are a carry over from the original K&R, and #if defined (blah) are ANSI C. The #if defined (blah) are a little more versatile in testing via the preprocessor, and prevents multiple nested #ifdef's. As a side note: These were put in to explicitly define some global variables in some header (.h) files, w/o redefining them in other files. Examples of this global variables are the global buffering system, found at the end of db.h. This is IMHO the wrong approach to doing this. The best way is to define them locally within a file, and within the header file, using an extern definition. Methods for this can be found in the Indian Hill style guide. something.c --------------------------------------------------------------------------- type global_variable; /* global variable */ something.h --------------------------------------------------------------------------- #ifndef __SOMETHING_H #define __SOMETHING_H extern type global_variable; #endif +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST