My (relatively old) C++ compiler choked on this file in Boost, which starts out as:
# /* Copyright (C) 2001
# * Housemarque Oy
# * http://www.housemarque.com
# *
# * Distributed under the Boost Software License, Version 1.0. (See
# * accompanying file LICENSE_1_0.txt or copy at
# * http://www.boost.org/LICENSE_1_0.txt)
# */
#
Is this really legal C++? What's the rule on the syntax of preprocessor tokens?
Yes, a line containing only # and whitespace is explicitly permitted by the standard §16 [cpp]:
control-line:
# includepp-tokens new-line
# defineidentifier replacement-list new-line
# defineidentifier lparen identifier-listopt)replacement-list new-line
# defineidentifier lparen... )replacement-list new-line
# defineidentifier lparen identifier-list, ... )replacement-list new-line
# undefidentifier new-line
# linepp-tokens new-line
# errorpp-tokensopt new-line
# pragmapp-tokensopt new-line
#new-line
Note that comments are replaced by whitespace at translation phase 3, that is before the preprocessor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With