CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2006
    Posts
    28

    How to read this, it seems like it has two types

    Here is the part thats causing the error

    #ifndef YY_SKIP_mbs_yysbuf
    #ifdef __cplusplus
    extern "C" int mbs_yysbuf YY_PROTO(( void ));
    #else
    extern int mbs_yysbuf YY_PROTO(( void ));
    #endif
    #endif


    Particularly, iam having trouble with

    extern int mbs_yysbuf YY_PROTO(( void ));

    I am not sure how do define mbs_yysbuf in my heaer file. If i do not define, there will be an error saying

    legacy error LNK2019: unresolved external symbol _mbs_yysbuf referenced in function _yylex

    Is int the type of YY_PROTO(( void )) or is mbs_yysbuf the type of YY_PROTO(( void ))??

    i believe the resolution is to define mbs_yysbuf in the header file, but i am not sure how to define it.
    Last edited by linhung; June 16th, 2006 at 09:07 AM.

  2. #2
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: How to read this, it seems like it has two types

    How did you come up with this problem? That is, why do you compile this code out of context?
    "Programs must be written for people to read, and only incidentally for machines to execute."

  3. #3
    Join Date
    Jun 2006
    Posts
    28

    Re: How to read this, it seems like it has two types

    Hi,

    This is part of the grogram. The compiler indicates this part is causing the error, so I pasted it on here seeking for help.

  4. #4
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: How to read this, it seems like it has two types

    Brilliant.

    add
    Code:
    #define mbs_yysbuf
    to get rid of it.
    "Programs must be written for people to read, and only incidentally for machines to execute."

  5. #5
    Join Date
    Jun 2006
    Posts
    28

    Re: How to read this, it seems like it has two types

    Quote Originally Posted by RoboTact
    Brilliant.

    add
    Code:
    #define mbs_yysbuf
    to get rid of it.
    Shouldnt I use #define mbs_yysbuf something, what should I put for something??

  6. #6
    Join Date
    Apr 1999
    Posts
    50

    Re: How to read this, it seems like it has two types

    The define you want is:

    Code:
    #define YY_PROTO (proto) proto
    This is a workround for old C compilers that did not allow you to declare the types of arguments to functions. There was actually never any need for it after #ifdef __cplusplus, but the author of your header file probably cut and pasted a definition.

    Hope that helps.

  7. #7
    Join Date
    May 2006
    Posts
    327

    Re: How to read this, it seems like it has two types

    Quote Originally Posted by linhung
    Shouldnt I use #define mbs_yysbuf something, what should I put for something??
    Try one of this:

    #define mbs_yysbuf // suggested by RoboTact

    #define mbs_yysbuf __stdcall

    #define mbs_yysbuf __cdecl

    #define mbs_yysbuf __fastcall

    #define mbs_yysbuf __thiscall

    or any of above in combination with __declspec(import), like this:

    #define mbs_yysbuf __declspec(import) __cdecl

  8. #8
    Join Date
    Apr 1999
    Posts
    50

    Re: How to read this, it seems like it has two types

    [QUOTE=Andrew Hain]The define you want is:

    Code:
    #define YY_PROTO (proto) proto
    [QUOTE]

    That should of course read:

    Code:
    #define YY_PROTO(proto) proto
    without a space before the ( .

  9. #9
    Join Date
    Jun 2006
    Posts
    28

    Re: How to read this, it seems like it has two types

    Thanks for the reply, now I am facing two new errors, and I believe they are related.

    I am getting two of the following error,
    talk_ll.c(4376): error C2375: 'input' : redefinition; different linkage
    talk_ll.c(6150): error C2375: 'input' : redefinition; different linkage

    The program around line 4376 is
    Code:
    #ifndef YY_NO_INPUT
        #ifdef __cplusplus
            static int mbs_yyinput YY_PROTO(( void ));
      #else
            static int input YY_PROTO(( void ));  <----   this is line 4376
        #endif
    #endif
    The program around line 6150 is
    Code:
    #ifdef __cplusplus
         static int mbs_mbs_yyinput()
    #else
         static int input()
    #endif
    {  <<---------  This is line 6150, but I believe the problem is coming from the above part
    
    // This is middle code, but I don't think its important with the problem I am encoutering. 
    }
    Basically, I think the problem might be the name of both parts are defined as "input". However, I cannot change anything inside this file (talk_ll.c) because it is directly coming from FLEX, the only file I can change is the header file (like, add define, add functions and stuff).

    I tried to add
    Code:
    static int input();
    into the header file, and that reduced to 1 error, saying
    talk_ll.c(6150): error C2084: function 'int input()' already has a body

    Does anyone know how to solve this?
    Last edited by linhung; June 16th, 2006 at 10:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured