restbed icon indicating copy to clipboard operation
restbed copied to clipboard

Compile errors with -DDEBUG

Open obucina opened this issue 4 years ago • 0 comments

Addresses the same problem as https://github.com/Corvusoft/restbed/issues/422

Test file, main.cpp

#include <restbed>

using namespace std;

int main(int argc, char **argv) {

    return 0;
}

Command line

g++ -DDEBUG=1 main.cpp

Output

<command-line>: error: expected identifier before numeric constant
<command-line>: error: expected ‘}’ before numeric constant
In file included from /usr/include/restbed:10,
                 from main.cpp:1:
/usr/include/corvusoft/restbed/logger.hpp:38:13: note: to match this ‘{’
   38 |             {
      |             ^
<command-line>: error: expected unqualified-id before numeric constant
In file included from /usr/include/restbed:10,
                 from main.cpp:1:
/usr/include/corvusoft/restbed/logger.hpp:50:13: error: ‘virtual’ outside class declaration
   50 |             virtual void stop( void ) = 0;
      |             ^~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:50:26: error: function ‘void restbed::stop()’ is initialized like a variable
   50 |             virtual void stop( void ) = 0;
      |                          ^~~~
/usr/include/corvusoft/restbed/logger.hpp:52:13: error: ‘virtual’ outside class declaration
   52 |             virtual void start( const std::shared_ptr< const Settings >& settings ) = 0;
      |             ^~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:52:26: error: function ‘void restbed::start(const std::shared_ptr<const restbed::Settings>&)’ is initialized like a variable
   52 |             virtual void start( const std::shared_ptr< const Settings >& settings ) = 0;
      |                          ^~~~~
/usr/include/corvusoft/restbed/logger.hpp:54:37: error: ‘Level’ does not name a type
   54 |             virtual void log( const Level level, const char* format, ... ) = 0;
      |                                     ^~~~~
/usr/include/corvusoft/restbed/logger.hpp:54:13: error: ‘virtual’ outside class declaration
   54 |             virtual void log( const Level level, const char* format, ... ) = 0;
      |             ^~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:54:26: error: function ‘void restbed::log(int, const char*, ...)’ is initialized like a variable
   54 |             virtual void log( const Level level, const char* format, ... ) = 0;
      |                          ^~~
/usr/include/corvusoft/restbed/logger.hpp:56:57: error: ‘Level’ does not name a type
   56 |             virtual void log_if( bool expression, const Level level, const char* format, ... ) = 0;
      |                                                         ^~~~~
/usr/include/corvusoft/restbed/logger.hpp:56:13: error: ‘virtual’ outside class declaration
   56 |             virtual void log_if( bool expression, const Level level, const char* format, ... ) = 0;
      |             ^~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:56:26: error: function ‘void restbed::log_if(bool, int, const char*, ...)’ is initialized like a variable
   56 |             virtual void log_if( bool expression, const Level level, const char* format, ... ) = 0;
      |                          ^~~~~~
/usr/include/corvusoft/restbed/logger.hpp:66:9: error: expected unqualified-id before ‘protected’
   66 |         protected:
      |         ^~~~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:74:30: error: expected unqualified-id before ‘const’
   74 |             explicit Logger( const Logger& original ) = default;
      |                              ^~~~~
/usr/include/corvusoft/restbed/logger.hpp:74:29: error: expected ‘)’ before ‘const’
   74 |             explicit Logger( const Logger& original ) = default;
      |                            ~^~~~~~
      |                             )
/usr/include/corvusoft/restbed/logger.hpp:76:35: error: declaration of ‘~restbed::Logger’ as non-member
   76 |             virtual ~Logger( void ) = default;
      |                                   ^
/usr/include/corvusoft/restbed/logger.hpp:85:21: error: ‘restbed::Logger& restbed::operator=(const restbed::Logger&)’ must be a nonstatic member function
   85 |             Logger& operator =( const Logger& value ) = default;
      |                     ^~~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:89:9: error: expected unqualified-id before ‘private’
   89 |         private:
      |         ^~~~~~~
/usr/include/corvusoft/restbed/logger.hpp:106:1: error: expected declaration before ‘}’ token
  106 | }
      | ^

I believe the problem is here

namespace restbed
{
    //Forward Declarations
    class Settings;
    
    class Logger
    {
        public:
            //Friends
            
            //Definitions
            enum Level : int
            {
                INFO = 0000,
        --->    DEBUG = 1000,
                FATAL = 2000,
                ERROR = 3000,
                WARNING = 4000,
                SECURITY = 5000
            };
...

Because same thing happens with

g++ -DINFO=1 main.cpp
g++ -DFATAL=1 main.cpp
g++ -DERROR=1 main.cpp
g++ -DWARNING=1 main.cpp
g++ -DSECURITY=1 main.cpp

obucina avatar Sep 30 '21 01:09 obucina