C++ compilation using mpic++ error

313 Views Asked by At

I'm trying to compile a program using mpic++ on a Linux system. The program contains source files provided by our professor and it's these files that throw the errors. In Visual Studio C++ there's no problem compiling the code but we are requiered to launch it on a Linux system, and when I move it to the Linux system to compile it using mpic++ an error occurs.

mpic++ -std=c++11 -Wall -c CommonApprox.cpp
In file included from ApproxIface.h:3:0,
                 from CommonApprox.h:3,
                 from CommonApprox.cpp:1:
referencedIface.h:23:19: error: '__stdcall' declared as a 'virtual' field
referencedIface.h:23:19: error: expected ';' at end of member declaration
referencedIface.h:23:90: error: ISO C++ forbids declaration of 'QueryInterface'           with no type [-fpermissive]
referencedIface.h:24:17: error: '__stdcall' declared as a 'virtual' field
referencedIface.h:24:17: error: expected ';' at end of member declaration
referencedIface.h:24:17: error: redeclaration of 'ULONG IReferenced::__stdcall'
referencedIface.h:23:19: note: previous declaration 'HRESULT IReferenced::__stdc          all'

The erorrs go on and on, these are just the first few. The code this particular error references is shown below.

#define IfaceCalling __stdcall

class IReferenced {
    /* Actually, this is IUnknown of the WinAPI's COM
    HRESULT and ULONG are used to allow possible and easy interoperability
    accross different compilers and languages on Windows
    */

public:
     virtual HRESULT IfaceCalling QueryInterface(/*REFIID */ void*  riid,     void ** ppvObj) = 0;
     virtual ULONG IfaceCalling AddRef() = 0;
     virtual ULONG IfaceCalling Release() = 0;
};

As far as I know, we are not allowed to alter the code that was provided to us.

Thank you for you help.

EDIT:

I use a makefile to compile the program.

OBJECTS = CommonApprox.o DatabaseHandler.o MaskHandler.o Output.o StatsHandler.o GlucoseLevels.o AkimaInterpolation.o CatmullRomInterpolation.o ApproxIface.o referencedImpl.o main.o

CFLAGS = -std=c++11 -Wall
LIBS = -lsqlite3 -ltbb
CC = mpic++

all: ku_ppr_distr

ku_ppr_distr : $(OBJECTS)
    $(CC) $(CFLAGS) $^ $(LIBS) -o $@ 
    rm -f *.o

CommonApprox.o: CommonApprox.cpp CommonApprox.h hresult.h
    $(CC) $(CFLAGS) -c CommonApprox.cpp

DatabaseHandler.o: DatabaseHandler.cpp DatabaseHandler.h
    $(CC) $(CFLAGS) -c DatabaseHandler.cpp

MaskHandler.o: MaskHandler.cpp MaskHandler.h 
    $(CC) $(CFLAGS) -c MaskHandler.cpp

Output.o: Output.cpp Output.h 
    $(CC) $(CFLAGS) -c Output.cpp

StatsHandler.o: StatsHandler.cpp StatsHandler.h
    $(CC) $(CFLAGS) -c StatsHandler.cpp

GlucoseLevels.o: GlucoseLevels.cpp GlucoseLevels.h
    $(CC) $(CFLAGS) -c GlucoseLevels.cpp

AkimaInterpolation.o: AkimaInterpolation.cpp AkimaInterpolation.h
    $(CC) $(CFLAGS) -c AkimaInterpolation.cpp

CatmullRomInterpolation.o: CatmullRomInterpolation.cpp CatmullRomInterpolation.h
    $(CC) $(CFLAGS) -c CatmullRomInterpolation.cpp

ApproxIface.o: ApproxIface.cpp ApproxIface.h
    $(CC) $(CFLAGS) -c ApproxIface.cpp

referencedImpl.o: referencedImpl.cpp referencedImpl.h
    $(CC) $(CFLAGS) -c referencedImpl.cpp

main.o: main.cpp
    $(CC) -w $(CFLAGS) -c main.cpp

%.o: %.c
    $(CC) -c $<  

clean: 
    rm -f *.o
1

There are 1 best solutions below

2
stanthomas On

mpic++ is a wrapper for g++ (the GNU C++ compiler on Linux). __stdcall is a Visual C++ specific compiler directive to control the generated code which is not recognised by g++. You might try adding a null definition for __stdcall to your makefile, i.e.

CFLAGS = -D__stdcall= -std=c++11 -Wall

That should get rid of quite a few error messages.