2010-05-07 11 views
50

मैं दृश्य स्टूडियो में मेरी जंगली भैंसों-उत्पन्न फ़ाइलों संकलित और मिल गया इन त्रुटियों:समस्या बुला std :: अधिकतम

... \ position.hh (83): त्रुटि C2589: '(': अवैध टोकन '::'
... \ position.hh (83): त्रुटि C2059: वाक्यविन्यास त्रुटि: '::'
... \ position.hh (83): त्रुटि C2589: '(' : के दाईं ओर अवैध टोकन '::'
... \ position.hh (83): त्रुटि C2059: सिंटेक्स त्रुटि: '::'

सह संबंधित कोड है:

inline void columns (int count = 1) 
{ 
    column = std::max (1u, column + count); 
} 

मुझे लगता है कि समस्या std :: max के साथ है; अगर मैं std :: max को समकक्ष कोड में बदलता हूं तो अब कोई समस्या नहीं है, लेकिन क्या जेनरेट कोड बदलने के बजाय कोई बेहतर समाधान है?

// 
// bison.yy 
// 

%skeleton "lalr1.cc" 
%require "2.4.2" 
%defines 
%define parser_class_name "cmd_parser" 
%locations 
%debug 
%error-verbose 

%code requires { 
class ParserDriver; 
} 

%parse-param { ParserDriver& driver } 
%lex-param { ParserDriver& driver } 

%union { 
    struct ast *a; 
    double d; 
    struct symbol *s; 
    struct symlist *sl; 
    int fn;   
} 

%code { 
#include "helper_func.h" 
#include "ParserDriver.h" 
std::string error_msg = ""; 
} 

%token <d> NUMBER 
%token <s> NAME 
%token <fn> FUNC 
%token EOL 
%token IF THEN ELSE WHILE DO LET 
%token SYM_TABLE_OVERFLOW 
%token UNKNOWN_CHARACTER 

%nonassoc <fn> CMP 
%right '=' 
%left '+' '-' 
%left '*' '/' 
%nonassoc '|' UMINUS 

%type <a> exp stmt list explist 
%type <sl> symlist 

%{ 
extern int yylex(yy::cmd_parser::semantic_type *yylval, 
yy::cmd_parser::location_type* yylloc); 
%} 

%start calclist 
%% 

... grammar rules ... 

उत्तर

107

आप शायद windows.h कहीं भी शामिल कर रहे हैं, जो max और min नामित मैक्रो परिभाषित करता है:

यहाँ जंगली भैंसों फ़ाइल मैंने लिखा है।

आप उन मैक्रो को परिभाषित करने से रोकने के लिए #define NOMINMAXwindows.h शामिल करने से पहले कर सकते हैं, या आप कोष्ठकों का एक अतिरिक्त सेट का उपयोग करके मैक्रो मंगलाचरण रोका जा सकता है:

column = (std::max)(1u, column + count); 
17

अपने स्रोत के शीर्ष पर NOMINMAX प्रतीक को परिभाषित करें, इससे पहले कि आप किसी भी शीर्षलेख शामिल करें। विजुअल सी ++ min और max को windows.h में मैक्रोज़ के रूप में परिभाषित करता है, और वे आपके मानक कार्यों के उपयोग में हस्तक्षेप करते हैं।

#define NOMINMAX 
संबंधित मुद्दे