0

I've got this class definition in a .h file, and the implementation in a .cpp file. When I try to compile this, the header file gives some errors and warnings:

    /home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:6: error: variable 'APEX_EXPORT ApexLoader' has initializer but incomplete type
 class APEX_EXPORT ApexLoader
                   ^
    /home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:6: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
    /home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:9: error: expected primary-expression before 'public'
 public:

The code in which this error occurs is:

#ifndef _APEXLOADER_H
#define _APEXLOADER_H

#include "global.h"

class APEX_EXPORT ApexLoader
{

public:
    int Load( int argc, char *argv[]);

};

#endif

With the "class APEX_EXPORT ApexLoader" being the line with the error and the warning.

The APEX_EXPORT is defined in a header file that is included from this same file.

EDIT: The APEX_EXPORT is defined in "global.h" as follows:

#ifdef APEX_MAKEDLL
    #define APEX_EXPORT APEX_EXPORT_DECL
#else
    #define APEX_EXPORT APEX_IMPORT_DECL
#endif

Does anyone know why these errors are there? And how can I get rid of them? Thank you in advance!

Compiler: gcc 4.8.4 OS: Ubuntu 14.04

DrDonut
  • 864
  • 14
  • 26
  • And what do the lines *before* the class look like? What is `APEX_EXPORT`? There's no other symbol `ApexLoader` (for example as a preprocessor macro)? – Some programmer dude Sep 01 '15 at 14:47
  • Where is APEX_EXPORT defined? If it's in another file, are you including that file in your header file? – Mike P Sep 01 '15 at 14:49
  • You haven't defined the macro `APEX_EXPORT`, so it looks like a declaration of a variable of type `class APEX_EXPORT`, named "ApexLoader". Exactly the same errors [here](http://ideone.com/A9Pc6M). – molbdnilo Sep 01 '15 at 14:50
  • How is `APEX_EXPORT_DECL` defined? And is `APEX_MAKEDLL` defined? – 001 Sep 01 '15 at 15:01

1 Answers1

9

My psychic debugging skills tell me that APEX_EXPORT isn't #defined and thus the compiler thinks you're trying to declare a variable of that type.

If you think you've included all the right headers the best way to go is to just run the preprocessor on your source file and see what it generates (for example g++ -E).

Mark B
  • 95,107
  • 10
  • 109
  • 188
  • You were right, it was not defined because of the following mistake: it was defined in the file global.h in my project, but I had also included another folder which also contained a different global.h file. Set the right include folder and all of a sudden it worked :) – DrDonut Sep 01 '15 at 15:18