Skip to content

Lines starting with "#" but contain no preprocessor code seem to confuse simplecpp #125

Closed

Description

@versat

As reported in the forum simplecpp seems to have problems with some include files from boost.
See for example config.hpp

For code like this (similar to how boosts config.hpp is written):

#
# if 1
#  define a 1
# endif

int main()
{
    printf("%d", a);
}

simplecpp reports this error:

$ ./simplecpp include.hpp

include.hpp:4: syntax error: #endif without #if

Removing the single # at the top makes it work again.
simplecpp also fails in the same way if a comment follows a # like this:

# //test
# if 1
#  define a 1
# endif

int main()
{
    printf("%d", a);
}

With gcc the output is just fine:

$ gcc -E include.hpp
# 1 "include.hpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "include.hpp"





int main()
{
    printf("%d", 1);
}

Activity

  1. self-assigned this
    on Apr 12, 2018
  2. amai2012 commented on Apr 12, 2018

    @amai2012
    Contributor

    http://en.cppreference.com/w/cpp/preprocessor says:

    The null directive (# followed by a line break) is allowed and has no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions