Menu

syntaxError when enum constant clashes with other type name

2024-12-18
2024-12-18
  • Frank Winklmeier

    The following is a minimal reproducer of a syntaxError that we encountered in our code base. The real example was much less evident as it was split over many includes:

    namespace NS1 {
      typedef NS2::Bar Bar;
      using NS2::MyType;
    }
    
    enum E : unsigned int {
      zero   =  0,
      MyType =  1
    };
    
    namespace NS1 {
    }
    

    results in

    test.cxx:6:1: error: syntax error [syntaxError]
    enum E : unsigned int {
    ^
    

    Change or remove any one line, or rename one of the "MyType", and the error goes away.

     
  • CHR

    CHR - 2024-12-18
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.