[GCC-XML] gccxml, export/import symbols
    Brad King 
    brad.king at kitware.com
       
    Fri Nov  4 16:03:20 EST 2005
    
    
  
Nicolas Hognon wrote:
> #define VK_MODULE_EXPORT __declspec(dllexport)
> 
> class Class1
> {
> public:
> 	VK_MODULE_EXPORT Class1();
[snip]
> In this case I've got an error in the line VK_MODULE_EXPORT Class1();
> Here is my command line with errors
> gccxml.exe --gccxml-compiler msvc71 -fxml=test.xml test.h
> test.h:14: error: declaration does not declare anything
> test.h:14: error: syntax error before `)' token
When gccxml simulates the MSVC 7.1 preprocessor it transforms 
__declspec(...) into __attribute__((...)) because that is the syntax the 
internal GCC parser uses to attach attributes like dllexport.  The 
problem you are seeing is that GCC wants the attributes for constructors 
to come AFTER the declaration:
class Class1
{
public:
   Class1() VK_MODULE_EXPORT;
...
};
Unfortunately this is a limitation of gccxml's implementation.  You can 
work-around it like this:
#if defined(__GCCXML__)
# define VK_MODULE_EXPORT_METHOD(x) x VK_MODULE_EXPORT
#else
# define VK_MODULE_EXPORT_METHOD(x) VK_MODULE_EXPORT x
#endif
class Class1
{
public:
   VK_MODULE_EXPORT_METHOD(Class1());
...
};
Something like this would have to be done to get the code to work on a 
MinGW or Cygwin compiler anyway.
-Brad
    
    
More information about the gccxml
mailing list