我已经阅读了关于这个主题的大部分相关答案,但我似乎无法发现我的代码有任何问题.以下是我的代码:
oneaborq.cc
...
#include "stdmacro.h"
...
class marker_t {
public:
signed_city_id_t val;
inline marker_t() { val = 0; };
inline signed_city_id_t is_true() { return val; };
inline signed_city_id_t is_false() { return (signed_city_id_t)!val; };
inline void make_true() { val = 1; };
inline void not() { val = (signed_city_id_t)!val; };
};
Run Code Online (Sandbox Code Playgroud)
stdmacro.h
#define LARGE_CITY_ID
...
typedef
#ifdef UNSIGNED_CITY_ID
unsigned
#else
signed
#endif
#ifdef LARGE_CITY_ID
short
#else
char
#endif
city_id_t;
/* signed_city_id_t is the same sizeof() as the city_id_t but can be negative
* and should be asserted not to go more than positive MAX_DEGREE/2
*/
typedef
signed
#ifdef LARGE_CITY_ID
short
#else
char
#endif
signed_city_id_t;
Run Code Online (Sandbox Code Playgroud)
我已经尝试在oneaborq.cc中将"signed_city_id_t"更改为显式"short"或"int",但这似乎没有帮助.我也尝试过将整个类定义更改为:
class marker_t {
public:
int val;
inline marker_t() { val = 0; };
inline int is_true() { return 0; };
inline int is_false() { return 0; };
inline void make_true() { val = 1; };
inline void not() { val = 0; };
};
Run Code Online (Sandbox Code Playgroud)
即使没有"!" 在整个类定义中,它仍然会得到相同的错误:"oneaborq.cc:207:错误:在'之前预期的非限定标识'!' 令牌"
我正在尝试在OS X上编译一个TSP(Travelins Salesman Problem)解算器(在这里找到:http://www.cs.sunysb.edu/~algorith/implement/tsp/distrib/tsp_solve),所以如果有人想要看到整个源代码,看看上面的链接.
inline void not() { val = (signed_city_id_t)!val; };
Run Code Online (Sandbox Code Playgroud)
not就像C++中的关键字一样,是!令牌的替代拼写.您不能将其用作函数的名称.