Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 once
#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!

like image 845
VextoR Avatar asked Mar 16 '11 17:03

VextoR


1 Answers

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

like image 127
Erik Avatar answered Oct 14 '22 13:10

Erik