Indentation of preprocessing directives

D

Dave

Hello all,

In standard C++, is it required that preprocessing directives (#include,
#if, etc...) start in column 0, or is that just a C thing?

Thank,
Dave
 
P

Phlip

Dave said:
In standard C++, is it required that preprocessing directives (#include,
#if, etc...) start in column 0, or is that just a C thing?

Obsolete Cs required column 0, I think. But the modern standards are
probably "first non-blank character is a # in a line".

Curiously, blanks may occur between the # and the following directive. So to
indent nested directives you could do this...

#ifndef db

# ifndef _DEBUG
# error don't use this in release mode
# endif

# include <sstream>
# include <iostream>
# include <string>

....or this:

#ifndef db

#ifndef _DEBUG
#error don't use this in release mode
#endif

#include <sstream>
#include <iostream>
#include <string>
 
J

Jack Klein

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Non-directives 4
Indentation styles 27
Preprocessing directives 3
indentation 5
Compile directives 1
## preprocessing issue 5
indentation blocking in Python 2
indentation 26

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top