c++ - 使用新的Mingw二进制文件在Cygwin中进行编译

标签 c++ c++11 compiler-errors

我更新了mingw二进制文件以支持c++ 11,现在我无法编译代码。

我正在使用Cygwin,并将二进制文件包含在PATH环境变量中。

这是我的include和main中的第一行:

#include "icm/icmCpuManager.hpp"
#include "Instruction.hpp"
#include "MicroblazeInstruction.hpp"
#include "CpuManager.hpp"
#include "File.hpp"
#include "Utils.hpp"

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <sstream>
#include <cstdint>

这将我带到File.hpp的第一行
#ifndef FILE_HPP
#define FILE_HPP

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <sstream>
#include <cstdint>

这是我的makefile:
IMPERAS=$(IMPERAS_HOME)
ifndef IMPERAS
  IMPERAS := $(error "IMPERAS paths not defined")
endif

SUFFIX=.cpp
CC=g++
CFLAGS=-O2 -Wall -c -I $(IMPERAS_HOME)/ImpPublic/include/host/ -std=c++11
LDFLAGS=-m32 -L$(IMPERAS_HOME)/bin/$(IMPERAS_ARCH) -lRuntimeLoader  

EXECUTABLE=./faith.exe
SRC=./main.cpp ./CpuManager.cpp ./Instruction.cpp ./File.cpp ./Utils.cpp
OBJS=$(SRC:.cpp=.o)
DEPS=

#SHAREDOBJ=$(SRC:.c=.so)

.PHONY: all
#all: $(EXECUTABLE) $(SHAREDOBJ)
all: $(EXECUTABLE)

# platform
$(EXECUTABLE): $(OBJS)
    @    echo "# Linking Platform $@"
    $(V) $(CC) $(OBJS) $(LDFLAGS) -o $@

# platform objects
%.o: %.cpp $(DEPS)
    @    echo "# Compiling Platform source: $@"
    $(V) $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@

# dynamic lib
#$(SHAREDOBJ): $(OBJS)
#   @    echo "# Host Linking Platform object $@"
#   $(V) $(CC) -shared -o $@ $^ $(LDFLAGS) 

.PHONY: clean
clean:
    $(V) - rm -f $(EXECUTABLE) $(OBJS)

这是我的编译错误:
$ make
# Compiling Platform source: main.o
g++ -m32 -LC:\Imperas/bin/Windows32 -lRuntimeLoader   -O2 -Wall -c -m32 -I C:\Imperas/ImpPublic/include/host/ -std=c++11 main.cpp -o main.o
In file included from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/ios_base.h:43:0,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ios:43,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ostream:40,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/iostream:40,
                 from File.hpp:4,
                 from main.cpp:5:
c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/locale_classes.h:45:1: error: expected unqualified-id before 'namespace'
In file included from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/cwctype:52:0,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/locale_facets.h:41,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/bits/basic_ios.h:39,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ios:45,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/ostream:40,
                 from c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/include/c++/iostream:40,
                 from File.hpp:4,
                 from main.cpp:5:
c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected '}' before end of line
c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected unqualified-id before end of line
c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/include/wctype.h:15:32: error: expected declaration before end of line
makefile:29: recipe for target 'main.o' failed
make: *** [main.o] Error 1

最佳答案

您在文件“CpuManager.hpp”的末尾缺少分号

缺少的分号会触发紧随其后的代码中的错误,该错误已在编译器错误中标识。

关于c++ - 使用新的Mingw二进制文件在Cygwin中进行编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31464210/

相关文章:

c++ - C++ 中的 int 和 double 运算

c++ - 来自 std :unique_ptr to bool 的隐式转换错误

c++ - 可以阻止 cin 等待输入吗?

c++ - 来自右值的非常量引用的无效初始化

c++ - 使用 std::enable_if 有什么问题?

C++ 头文件和链接器错误

arrays - Swift - Any - 无法将类型 MyType<Int> 的值转换为预期的元素类型 MyType<protocol<>>

c++ - 如何在verilog模块上运行SPECfp基准测试?

c++ - 在 C++ 0x 中 boost lambda::_1

简单迭代程序中的Java方法类型错误