position.hh:46:错误:预期“命名空间”之前,不合格-ID
-
19-09-2019 - |
题
下面是我的代码:
34
35 /**
36 ** \file position.hh
37 ** Define the example::position class.
38 */
39
40 #ifndef BISON_POSITION_HH
41 #define BISON_POSITION_HH
42
43 #include <iostream>
44 #include <string>
45
46 namespace example
47 {
48 /// Abstract a position.
49 class position
50 {
51 public:
52
53 /// Construct a position.
54 position ()
55 : filename (0), line (1), column (0)
56 {
谢谢,调速装置,这是伟大的。 Necrolis,谢谢你。无论你们是在对编译单元相同的轨道。下面是完整的错误报告:
在文件从location.hh包括:45, 从parser.h:64, 从scanner.h:25, 从scanner.ll:8: position.hh:46:错误:预期“命名空间”
前不合格-IDlocation.hh看起来像这样:
35 /**
36 ** \file location.hh
37 ** Define the example::location class.
38 */
39
40 #ifndef BISON_LOCATION_HH
41 # define BISON_LOCATION_HH
42
43 # include <iostream>
44 # include <string>
45 # include "position.hh"
46
47 namespace example
48 {
49
50 /// Abstract a location.
51 class location
52 {
53 public:
我还要补充正在由野牛生成这些文件。这是当我尝试编译通过柔性++,我得到这个阶段生成的C ++扫描器类。我通过发出获取.CC代码挠曲--c ++ -o scanner.cc scanner.ll。
解决方案
这种情况发生时;或其他一些事情关闭缺少的命名空间之前。你确定34前行没有代码?如果它们具有代码(即使该代码是其他的#include)的误差是存在的。
编辑:或者,在所有情况下34行没有代码,错误是在包括该标题中的文件,很可能有没有结束的码;或}或)或某些其他结束字符,和后右它(忽略评论,当然)有将#include position.hh
或者如果有两个包括在一排中,一个前position.hh,包括position.hh前报头的最后几行是与错误,通常是一个结构,而没有一个;关闭之后}
其他提示
在错误可能在比其报告(由于编译单元)的文件以外的文件中存在的,即位于或靠近该“其他”文件(如端部的缺“}”或“;”或 '#ENDIF' 等)
不隶属于 StackOverflow