What is the difference between ...
What's the difference between const MAXSIZE = 100; and #define MAXSIZE 100 A preprocessor #define gives you a true compile-time constant. In C, const gives you a run-time object which you're not supposed to try to modify; ``const'' really means ``readonly''. 2016-02-18, 527👍, 0💬
I am splitting up a program into multiple source files for the first time ...
I'm splitting up a program into multiple source files for the first time, and I'm wondering what to put in .c files and what to put in .h files. (What does ``.h'' mean, anyway?) As a general rule, you should put these things in header (.h) files: macro definitions (preprocessor #defines) structure, ... 2016-02-18, 554👍, 0💬
Is it acceptable for one header file to #include another?
Is it acceptable for one header file to #include another? It's a question of style, and thus receives considerable debate. Many people believe that ``nested #include files'' are to be avoided: the prestigious Indian Hill Style Guide disparages them; they can make it harder to find relevant definitio... 2016-02-16, 631👍, 0💬
What's the difference between...?
What's the difference between #include <> and #include "" ? The syntax is typically used with Standard or system-supplied headers, while "" is typically used for a program's own header files. 2016-02-16, 525👍, 0💬
What are the complete rules for header file searching?
What are the complete rules for header file searching? The exact behavior is implementation-defined (which means that it is supposed to be documented; Typically, headers named with <> syntax are searched for in one or more standard places. Header files named with "" syntax are first searched ... 2016-02-12, 599👍, 0💬
I am getting strange syntax errors on the very first declaration in a file, but it looks fine.
I am getting strange syntax errors on the very first declaration in a file, but it looks fine. Perhaps there's a missing semicolon at the end of the last declaration in the last header file you're #including. 2016-02-12, 479👍, 0💬
I am using header files which accompany two different third-party libraries...
I'm using header files which accompany two different third-party libraries, and they are ``helpfully'' defining common macros such as TRUE, FALSE, Min(), and Max(), but the definitions clash with each other and with definitions I'd already established in my own header files. What can I do? This is i... 2016-02-10, 584👍, 0💬
I am including the right header file for the library function I am using, but the linker keeps saying its undefined.
I am including the right header file for the library function I am using, but the linker keeps saying its undefined. In the general case of calling code in an external library, using #include to pull in the right header file(s) is only half of the story; you also have to tell the linker to search th... 2016-02-10, 622👍, 0💬
I mm compiling a program, and I seem to be missing one of the header files it requires
I mm compiling a program, and I seem to be missing one of the header files it requires There are several situations, depending on what sort of header file it is that's ``missing''. If the missing header file is truly a standard one (that is, one defined by the ANSI C Standard, such as <stdio.... 2016-02-05, 626👍, 0💬
How can I construct preprocessor if expressions which compare strings?
How can I construct preprocessor if expressions which compare strings? You can't do it directly; preprocessor #if arithmetic uses only integers. An alternative is to #define several macros with symbolic names and distinct integer values, and implement conditionals on those: #define RED 1 #define BLU... 2016-02-05, 635👍, 0💬
Does the sizeof operator work in preprocessor if directives?
Does the sizeof operator work in preprocessor if directives? No. Preprocessing happens during an earlier phase of compilation, before type names have been parsed. Instead of sizeof, consider using the predefined constants in ANSI's <limits.h>, if applicable, or perhaps a ``configure'' script.... 2016-02-03, 569👍, 0💬
Can I use an ifdef in a #define line ...
Can I use an #ifdef in a #define line, to define something two different ways, like this? #define a b \ #ifdef whatever c d #else e f g #endif No. You can't ``run the preprocessor on itself,'' so to speak. What you can do is use one of two completely separate #define lines, depending on the #ifdef s... 2016-02-03, 624👍, 0💬
Is there anything like an ifdef for typedefs?
Is there anything like an ifdef for typedefs? Unfortunately, no. (There can't be, because types and typedefs haven't been parsed at preprocessing time.) You may have to keep sets of preprocessor macros (e.g. MY_TYPE_DEFINED) recording whether certain typedefs have been declared. 2016-02-01, 636👍, 0💬
How can I use a preprocessorif expression to ? ....
How can I use a preprocessor #if expression to tell whether a machine's byte order is big-endian or little-endian? You probably can't. The usual techniques for detecting endianness involve pointers or arrays of char, or maybe unions, but preprocessor arithmetic uses only long integers, and there is ... 2016-02-01, 595👍, 0💬
I a'm getting strange syntax errors inside lines I have ifdeffed out.
I a'm getting strange syntax errors inside lines I have ifdeffed out. Under ANSI C, the text inside a ``turned off'' #if, #ifdef, or #ifndef must still consist of ``valid preprocessing tokens.'' This means that the characters " and ' must each be paired just as in real C code, and the pairs mustn't ... 2016-01-29, 656👍, 0💬
I inherited some code which contains far too many ...
I inherited some code which contains far too many #ifdef's for my taste. How can I preprocess the code to leave only one conditional compilation set, without running it through the preprocessor and expanding all of the #include's and #define's as well? There are programs floating around called unifd... 2016-01-29, 595👍, 0💬
How can I list all of the predefined identifiers?
How can I list all of the predefined identifiers? There's no standard way, although it is a common need. gcc provides a -dM option which works with -E, and other compilers may provide something similar. If the compiler documentation is unhelpful, the most expedient way is probably to extract printab... 2016-01-27, 612👍, 0💬
I have some old code that tries to construct identifiers with a macro like ...
I have some old code that tries to construct identifiers with a macro like #define Paste(a, b) a/**/b but it doesn't work any more. It was an undocumented feature of some early preprocessor implementations (notably Reiser's) that comments disappeared entirely and could therefore be used for token pa... 2016-01-27, 591👍, 0💬
I have an old macro that doesn't seem to work any more....
I have an old macro #define CTRL(c) ('c' & 037) that doesn't seem to work any more. The intended use of this macro is in code like tchars.t_eofc = CTRL(D); which is expected to expand to tchars.t_eofc = ('D' & 037); based on the assumption that the actual value of the parameter c wil... 2016-01-25, 538👍, 0💬
Why is the macro giving me the warning
Why is the macro #define TRACE(n) printf("TRACE: %d\n", n) giving me the warning ``macro replacement within a string literal''? It seems to be expanding TRACE(count); as printf("TRACE: %d\count", count); Some pre-ANSI compilers/preprocessors interpreted macro definitions like #define TRACE(var, fmt)... 2016-01-25, 523👍, 0💬
How can I use a macro argument inside a string literal in the macro expansion?
How can I use a macro argument inside a string literal in the macro expansion? Some pre-ANSI compilers/preprocessors interpreted macro definitions like #define TRACE(var, fmt) printf("TRACE: var = fmt\n", var) such that invocations like TRACE(i, %d); were expanded as printf("TRACE: i = %d\n", i); In... 2016-01-22, 567👍, 0💬
I am trying to use the ANSI stringizing preprocessing operator ....
I'm trying to use the ANSI ``stringizing'' preprocessing operator `#' to insert the value of a symbolic constant into a message, but it keeps stringizing the macro's name rather than its value. It turns out that the definition of # says that it's supposed to stringize a macro argument immediately, w... 2016-01-22, 630👍, 0💬
I have got this tricky preprocessing I want to do and I cant figure out a way to do it.
I have got this tricky preprocessing I want to do and I cant figure out a way to do it. C's preprocessor is not intended as a general-purpose tool. (Note also that it is not guaranteed to be available as a separate program.) Rather than forcing it to do something inappropriate, you might want to wri... 2016-01-19, 583👍, 0💬
How can I write a macro which takes a variable number of arguments ....
How can I write a macro which takes a variable number of arguments, or use the preprocessor to ``turn off'' a function call with a variable number of arguments? One popular trick is to define and invoke the macro with a single, parenthesized ``argument'' which in the macro expansion becomes the enti... 2016-01-19, 596👍, 0💬
In which event are the controls fully loaded ? Page_load event guarantees that all controls are full...
How is the MVC design pattern used in Struts framework? In the MVS design pattern, there 3 component...
How To Export Your Connection Information to a File? - Oracle DBA FAQ - Introduction to Oracle SQL D...
What does AddressOf operator do in background ? The AddressOf operator creates a delegate object to ...