Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParserException Unexpected token with macros within a namespace #63

Closed
jpsacha opened this issue Jan 23, 2016 · 2 comments
Closed

ParserException Unexpected token with macros within a namespace #63

jpsacha opened this issue Jan 23, 2016 · 2 comments
Labels

Comments

@jpsacha
Copy link
Member

jpsacha commented Jan 23, 2016

Parsing a macro within a namespace can lead to an error:

Exception in thread "main" org.bytedeco.javacpp.tools.ParserException: null:10: Unexpected token '?'
        at org.bytedeco.javacpp.tools.Token.expect(Token.java:99)
        at org.bytedeco.javacpp.tools.Parser.namespace(Parser.java:2498)
        at org.bytedeco.javacpp.tools.Parser.declarations(Parser.java:2589)
        at org.bytedeco.javacpp.tools.Parser.parse(Parser.java:2665)
        at org.bytedeco.javacpp.tools.Parser.parse(Parser.java:2762)
        at org.bytedeco.javacpp.tools.Builder.parse(Builder.java:68)
        at org.bytedeco.javacpp.tools.Builder.build(Builder.java:622)
        at org.bytedeco.javacpp.tools.Builder.main(Builder.java:771)

Here is a sample C++ header code that will cause an eror:

namespace cimg_library_suffixed {

    bool is_sameN(const unsigned int size_n) const {
      return _width==size_n;
    }   

#define _cimglist_def_is_same1(axis) \
    bool is_same##axis(const unsigned int val) const { \
      bool res = true; for (unsigned int l = 0; l<_width && res; ++l) res = _data[l].is_same##axis(val); return res; \
    } \
    bool is_sameN##axis(const unsigned int n, const unsigned int val) const { \
      return is_sameN(n) && is_same##axis(val); \
    } \


    _cimglist_def_is_same1(X)
    _cimglist_def_is_same1(Y)   

}

Note that when namespece is commented out (no namespace is used) then there are no issues.

@saudet saudet added the bug label Jan 24, 2016
saudet added a commit that referenced this issue Jan 24, 2016
@saudet
Copy link
Member

saudet commented Jan 24, 2016

Should be fixed in latest commit. Thanks for reporting!

@jpsacha
Copy link
Member Author

jpsacha commented Jan 24, 2016

The fix works. Thanks.

@jpsacha jpsacha closed this as completed Jan 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants