On Monday 18 April 2005 07:54, Jerry Feldman wrote:
On Mon, 18 Apr 2005 02:22:26 +1000
Colin Carter
wrote: A macro you say! This I didn't know. I think of a NUL as being the ASCII character/byte being a full house of zero bits. The same as used at the end of a C string. You know, like ACK, BEL, HT, ETX, et cetera To make a FORTRAN character string acceptable to a C routine one might use:
StringFred(1:6) = "Hello" // char(0) where // is the FORTRAN symbol for concatenate.
How does the C macro work?
More specifically, a C Preprocessor macro. These are defined using the #define command. #define NULL 0 or #define NULL ((void *)0)
Jerry, this is where I normally get into trouble. Some C functions require an integer and some a pointer, and when examples just supply a NULL I inevitably get a incorrect type warning. I understand what you said (above), and I know that a full house of zeros can be an integer or a NULL pointer, but how can the C include files define it BOTH ways above, or does the preprocessor just insert a zero? Colin
The C or C++ source is first preprocessed through the C preprocessor before the compiler's lex step. Most modern compilers combine the preprocessor with lex, but it is stipp a unique command on many Linux and Unix systems. Other languages, like FORTRAN on Linux and Unix also use the preprocessor. In C, if you want to define a constant, you generally use a macro. In C+ +, the const keyword lets you define a true constant. -- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9