我正在尝试在 Linux 系统上使用 mpic++ 编译程序。该程序包含我们教授提供的源文件,正是这些文件引发了错误。在 Visual Studio C++ 中编译代码没有问题,但我们需要在 Linux 系统上启动它,当我将它移动到 Linux 系统以使用 mpic++ 编译它时出现错误。
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'
错误不断发生,这些只是最初的几个。此特定错误引用的代码如下所示。
#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;
};
据我所知,我们不允许更改提供给我们的代码。
谢谢你的帮助。
编辑:
我使用makefile来编译程序。
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