No, not for the #include
statements you're specifically mentioning in your question. And, though I haven't specifically checked(a), that's probably the case for all preprocessing directives.
The standard states that the newline is an integral part of the syntax (from C11 6.10.2 Source file inclusion
):
A preprocessing directive of the form
# include <h-char-sequence>
new-line
...
You can place a comment after an #include
directive since replacements of comments with a single space happens in phase 3, whereas pre-processing directives are handled in phase 4 (see C11 5.1.1.2 Translation phases
).
But that doesn't help you with trying to place non-comments like the main()
function definition on the same line, that's still a no-no.
But my question to you would be: why on Earth would you want to do this? Simply output two lines and be done with it. It's not like we're suffering a world-wide shortage of newline characters :-)
(a) Jonathan Leffler has checked, so this statement is almost certainly correct.
From ISO/IEC 9899:2011, §6.10 Preprocessing directives:
# if
constant-expression new-line groupopt
# ifdef
identifier new-line groupopt
# ifndef
identifier new-line groupopt
# elif
constant-expression new-line groupopt
# else
new-line groupopt
# endif
new-line
# include
pp-tokens new-line
# define
identifier replacement-list new-line
# define
identifier lparen identifier-listopt ) replacement-list new-line
# define
identifier lparen ... ) replacement-list new-line
# define
identifier lparen identifier-list , ... ) replacement-list new-line
# undef
identifier new-line
# line
pp-tokens new-line
# error
pp-tokensopt new-line
# pragma
pp-tokensopt new-line
#
new-line