Quantcast
Channel: Complete, Concrete, Concise » C
Browsing all 11 articles
Browse latest View live

Preprocessor – the #elif Directive

This (along with the #if directive) is probably the second most complicated preprocessor directive because the controlling expression can be complex and include tricky macro replacements. #elif is one...

View Article



Preprocessor – the #ifndef Directive

Behaviour of the #ifndef directive is the same in both C and C++. Purpose The #ifndef directive is one of five preprocessor selection statements allowing selection of alternative sections of code for...

View Article

Preprocessor – the #else Directive

#else is one of five preprocessor selection statements allowing selection of alternative sections of code for compilation. The other four selection statements are: #ifdef, #ifndef, #if, and #elif....

View Article

Preprocessor – the #endif Directive

Behaviour of this preprocessor directive is the same for both C and C++ compilers. Purpose The #endif directive is used end / close / terminate a selection block (#if, #ifdef, or #ifndef. Format #if...

View Article

Preprocessor – Understanding the stringizing (#) Operator

This is one of three preprocessor operators. The other two operators are the token pasting operator (##) and the define operator. The behaviour is the same for both C and C++ compilers. Purpose The...

View Article


Preprocessor – the #pragma Directive

Behaviour of this preprocessor directive is the same for both C and C++ compilers. Behaviour of this directive is very likely to vary from one compiler vendor to another. Purpose The #pragma directive...

View Article

Preprocessor – the #line Directive

I don’t think I have ever seen this directive used. Behaviour of this preprocessor directive is the same for both C and C++ compilers. Purpose The #line directive allows setting the current line...

View Article

Preprocessor – the #error Directive

Preprocessor – the #error Directive This is a very useful and often underused preprocessor directive. Behaviour of this preprocessor directive is the same for both C and C++ compilers. Purpose The...

View Article


How to Add Comments to Macros

Comments are an important part of documenting your code. Adding comments to macros is quite easy, but it has to be done the right way. This works with both C and C++ compilers. The easiest way to...

View Article


Keyword – switch, case, default

The switch keyword is probably the least well understood of the C/C++ language keywords (although, const probably comes a close second). The keywords switch, case, and default always go together and...

View Article

Programming Error – Unintended String Concatenation

In an effort to be helpful, C and C++ compilers concatenate adjacent strings together. In the following example, the compiler will concatenate the two strings into a single string: printf("This is a...

View Article
Browsing all 11 articles
Browse latest View live




Latest Images