tema
tema

Reputation: 1125

C2470 error Visual Studio 2012 and Qt 4.8.6

I'm making small lib for my R&D needs. For that needs I use Qt 4.8.6 and Visual Stuido 2012.


Here's my .pro file

TEMPLATE    = lib
TARGET      = mylib
CONFIG      += dll

HEADERS = mymath.h

SOURCES = mymath.cpp \

INCLUDEPATH +=  ../include \

DEFINES += MYMATHIMPL

Here's .h file with my class

#ifndef MY_MATH_H
#define MY_MATH_H

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <float.h>


#if defined(MYMATHIMPL)
# define MYMATHAPI Q_DECL_EXPORT
#else
# define MYMATHAPI Q_DECL_IMPORT
#endif

typedef struct
{
  double * b;
  double * c;
  double * d;
  double * _m;
} akima_state_t;

class MYMATHAPI AkimaInterpolator
{
public:
    AkimaInterpolator(double * _x_values, double * _y_values, size_t size);
    AkimaInterpolator(double *d, double *c, double* b, double *_x_values, double* _y_values, size_t _size);
    ~AkimaInterpolator();
    double evaluateAtX(double x);
    static int searchIndex(const double sortedArray[], double toFind, int len);
};

.cpp file contains all declared method with implementation as well.
But when I'm trying to build this library I've got error:

mymath.h(31): error C2470: AkimaInterpolator:: looks like a function definition, but there is no parameter list; skipping apparent body.

I've checked comiler flags and it seems that MYMATHIMPL is set.

cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DACPMATHIMPL -D_DEBUG -D__STDC_LIMIT_MACROS -D__ST
    DC_FORMAT_MACROS -DSPM_VERSION_INFO -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -D
    QT_THREAD_SUPPORT -I"c:\Qt\4.8.6\include\QtCore" -I"c:\Qt\4.8.6\include\QtGui" -I"c:\Qt\4.8.6\include" -I"..\include" -I"..\..\common\include" -I"-I"..\..\common\include" -I"..\
    ..\common\include" -I"c:\Qt\4.8.6\include\ActiveQt" -I"..\..\..\temp\acp_v2\debug" -I"c:\Qt\4.8.6\mkspecs\win32-msvc2012" -Fo..\..\..\temp\acp_v2\debug\ @C:\Users\admin\AppData\Local\Temp\nmC62D.tmp

What am I doing wrong? Why block:

#if defined(MYMATHIMPL)
    # define MYMATHAPI Q_DECL_EXPORT
#else
    # define MYMATHAPI Q_DECL_IMPORT
#endif

doesn't work as expected?

Upvotes: 0

Views: 337

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254431

You haven't included any QT headers that might define Q_DECL_EXPORT or Q_DECL_IMPORT, nor are they defined by the command line. So your use of MYMATHAPI is expanded to Q_DECL_EXPORT, rather than whatever that's supposed to expand to.

I think they are defined in <QtGlobal>.

Upvotes: 1

Related Questions