【问题标题】:Can't figure out error无法判断错误
【发布时间】:2011-09-09 15:11:40
【问题描述】:

我正在尝试让 google glog 与 Windows 一起工作,但我遇到了这些我无法弄清楚的错误。

// Variables of type LogSeverity are widely taken to lie in the range
// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
// you ever need to change their values or add a new severity.
typedef int LogSeverity;

const int INFO = 0;
const int WARNING = 1; 
const int ERROR = 2;
const int FATAL = 3;
const int NUM_SEVERITIES = 4;


1>c:\users\<me>\documents\visual studio 2008\projects\sampleproj\sampleproj\src\windows\glog\log_severity.h(53) : warning C4091: '' : ignored on left of 'const int' when no variable is declared
1>c:\users\<me>\documents\visual studio 2008\projects\sampleproj\sampleproj\src\windows\glog\log_severity.h(53) : error C2143: syntax error : missing ';' before 'constant'
1>c:\users\<me>\documents\visual studio 2008\projects\sampleproj\sampleproj\src\windows\glog\log_severity.h(53) : error C2059: syntax error : 'constant'

【问题讨论】:

  • 错误出现在您未向我们展示的程序部分。请提供一个最小的、完整的程序来演示错误。有关为什么这很重要以及如何做到这一点的信息,请参阅sscce.org
  • 问题中提供的代码很好。您可能在 typedef int LogSeverity; 行之前的某处缺少分号。查看log_severity.hlog_severity.h 包含的所有文件中的typedef 之前是否缺少分号。
  • 我正在处理一个基本的 Windows 项目(只是写 hello world),但你一定是对的。我创建了一个空项目,它似乎工作。奇数。

标签: c++ compiler-errors logging


【解决方案1】:

显示的代码有这一行:

#define INFO 0

这意味着编译器看到的代码是这样的:

const int 0 = 0;

当然不会编译。

【讨论】:

    【解决方案2】:

    错误应该在其他地方,也许在以前的标题中?

    您发布的代码编译没有问题:http://ideone.com/Wf64q

    【讨论】:

      【解决方案3】:

      您的标识符与在其他地方定义的某些宏名称冲突。您可能已经包含了一些已经定义了具有该名称的宏的 Windows 头文件。

      【讨论】:

        猜你喜欢
        • 2017-08-14
        • 2014-06-16
        • 1970-01-01
        • 2012-05-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-26
        • 1970-01-01
        相关资源
        最近更新 更多