开发者

class exporting error (error C2470: looks like a function definition)

开发者 https://www.devze.com 2023-02-17 09:58 出处:网络
I can\'t export a class: #ifndef SDBIDI #define SDBIDI #ifndef SDBIDI_FLAG #define SDBIDI_ORIENT __declspec(dllimport)

I can't export a class:

#ifndef SDBIDI
#define SDBIDI
#ifndef SDBIDI_FLAG
#define SDBIDI_ORIENT __declspec(dllimport)
#else
#define SDBIDI_ORIENT __declspec(dllexport)
#endif

#include "TCInfoSuVars.h" //class is here!

SDBIDI_ORIENT int myFoo(FILE *file); // exporting function

#endif

class definition in TCInfoSuVars.h

#pragma on开发者_开发百科ce
#include <string>
#include <hash_map>

class SDBIDI_ORIENT TCInfoSuVars
{
public:
    std::string id;
    std::string tcVal;

    TCInfoSuVars();
    TCInfoSuVars(std::string _tcVal, std::string _id);

    ~TCInfoSuVars();
};

Getting a error:

myProgram.cpp

#define SDBIDI_FLAG

output:

TCInfoSuVars.h(14) : error C2470: 'TCInfoSuVars' : looks like a function definition, but there is no parameter list; skipping apparent body

And if I write

class __declspec(dllexport) TCInfoSuVars

everything works OK.

Thank you!


Somewhere you're including TCInfoSuVars.h before SDBIDI_ORIENT is defined - Make sure you include the header file that defines SDBIDI_ORIENT first.

0

精彩评论

暂无评论...
验证码 换一张
取 消