Not compiling typedef definition
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Not compiling typedef definition

  1. #1
    Join Date
    Apr 2012
    Posts
    29

    Not compiling typedef definition

    Hello,

    Im migrating a VC++ 6.0 code to VS 2010. There is not compiling a file from Visual Studio itself: oaidl.h on the line

    Code:
    typedef CY CURRENCY;
    line 226

    it says:

    1>c:\program files\microsoft sdks\windows\v7.0a\include\oaidl.h(226): error C2143: syntax error : missing ';' before 'constant'
    1>c:\program files\microsoft sdks\windows\v7.0a\include\oaidl.h(226): error C2059: syntax error : 'constant'

    any clue?

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,526

    Re: Not compiling typedef definition

    Quote Originally Posted by michaelhsilva View Post
    ...any clue?
    Yes, some clues
    Your error means that the type CY is not defined.
    It *should* be defined in <WTypes.h>, included in <winscard.h>, that is in turn included in <windows.h>.
    You could bypass any of these inclusions by using some preprocessor definitions.
    My bet is you have defined WIN32_LEAN_AND_MEAN. Did I win?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  3. #3
    Join Date
    Apr 2012
    Posts
    29

    Question Re: Not compiling typedef definition

    Hello VladmirF, thank you for your post!

    No, Ive not defined WIN32_LEAN_AND_MEAN. I defined CY on WTypes.h but it appeared another errors:

    1>c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(2): error C2143: syntax error : missing ';' before 'constant'
    1>c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(1052): error C2371: 'CY' : redefinition; different basic types
    1> c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(2) : see declaration of 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2071): error C2766: explicit specialization; 'ATL::_CVarTypeInfo<int>' has already been defined
    1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(1839) : see previous definition of '_CVarTypeInfo<int>'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2073): error C2374: 'pmField' : redefinition; multiple initialization
    1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(1842) : see declaration of 'pmField'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2081): error C2766: explicit specialization; 'ATL::_CVarTypeInfo<int*>' has already been defined
    1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(1849) : see previous definition of '_CVarTypeInfo<int *>'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2083): error C2374: 'pmField' : redefinition; multiple initialization
    1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(1852) : see declaration of 'pmField'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2465): error C2535: 'ATL::CComVariant &ATL::CComVariant:perator =(int)' : member function already defined or declared
    1> c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2397) : see declaration of 'ATL::CComVariant:perator ='
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2216): error C2228: left of '.Hi' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2216): error C2228: left of '.Hi' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2217): error C2228: left of '.Lo' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2217): error C2228: left of '.Lo' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2471): error C2228: left of '.Hi' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2471): error C2228: left of '.Hi' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2472): error C2228: left of '.Lo' must have class/struct/union
    1> type is 'CY'
    1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2472): error C2228: left of '.Lo' must have class/struct/union
    1> type is 'CY'

    this is very strange, a file of Visual Studio itself!

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,526

    Re: Not compiling typedef definition

    Quote Originally Posted by michaelhsilva View Post
    ... I defined CY on WTypes.h but it appeared another errors:

    1>c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(2): error C2143: syntax error : missing ';' before 'constant'
    What do you mean - "I defined"???
    The type CY *IS* defined in <WTypes.h>, on line # 1051!
    Line # 2 in that file has a comment.
    Did you type something in yourself?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

  5. #5
    Join Date
    Apr 2012
    Posts
    29

    Re: Not compiling typedef definition

    Quote Originally Posted by VladimirF View Post
    What do you mean - "I defined"???
    I just put
    Code:
    typedef CY CURRENCY
    on <WTypes.h>

    Quote Originally Posted by VladimirF View Post
    The type CY *IS* defined in <WTypes.h>, on line # 1051!
    Yes, there really is.

    Quote Originally Posted by VladimirF View Post
    Line # 2 in that file has a comment.
    Yes /* this ALWAYS GENERATED file contains the definitions for the interfaces */

    Quote Originally Posted by VladimirF View Post
    Did you type something in yourself?
    I just put
    Code:
    typedef CY CURRENCY
    on <WTypes.h>

  6. #6
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Not compiling typedef definition

    Why are you editing a delivered include file?

    You can't put the typedef before the definition of "CY".

    Viggy

  7. #7
    Join Date
    Apr 2012
    Posts
    29

    Question Re: Not compiling typedef definition

    Hello MRViggy, thank you for your post!

    I mean, this is a delivered file, why it has compilation errors?

  8. #8
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Not compiling typedef definition

    You said:
    Quote Originally Posted by michaelhsilva
    I defined CY on WTypes.h but it appeared another errors
    and
    Quote Originally Posted by michaelhsilva
    I just put
    Code:
    typedef CY CURRENCY
    on <WTypes.h>
    I took that to mean that you hand edited the file. The first three lines in your log lead me to believe that you had added the 'typedef' to the header file before the declaration of "CY".

    Viggy

  9. #9
    Join Date
    Apr 2012
    Posts
    29

    Question Re: Not compiling typedef definition

    Yes, I set but then pulled off.

    I have:

    Code:
    typedef CY *LPCY;
    on wtypes.h:1053

    and:

    Code:
    typedef CY CURRENCY;
    on oaidl.h:226

    The question is, why this latter is causing compilation errors?:

    oaidl.h(226): error C2143: syntax error : missing ';' before 'constant'
    oaidl.h(226): error C2059: syntax error : 'constant'

  10. #10
    Join Date
    Apr 2012
    Posts
    29

    Re: Not compiling typedef definition

    I made a simple application with the code:

    Code:
    #include "stdafx.h"
    
    typedef CY; *LPCY;
    typedef CY CURRENCY;
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	return 0;
    }
    and it works!

  11. #11
    Join Date
    Apr 2012
    Posts
    29

    Arrow Re: Not compiling typedef definition

    but Im still needing help on the main application... The error persists.

  12. #12
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Not compiling typedef definition

    The error message looks like there might be some kind of pre-processor macro defined in one of your header files.

    Viggy

  13. #13
    Join Date
    Apr 2012
    Posts
    29

    Talking Re: Not compiling typedef definition

    Solution: changed for

    Code:
    typedef CY; //CURRENCY;
    may be?

  14. #14
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Not compiling typedef definition

    Quote Originally Posted by michaelhsilva View Post
    Solution: changed for

    Code:
    typedef CY; //CURRENCY;
    may be?
    No. That line really says nothing. And, you shouldn't be modifying SDK header files, unless you wrote them. It seems like you might have something in one of your header files, not Windows header files, that might be changing CURRENCY to something else. If you add the compiler option "/E" you can see what the preprocessor is doing. Search the output for "CURRENCY".

    Viggy

  15. #15
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,553

    Re: Not compiling typedef definition

    Quote Originally Posted by michaelhsilva View Post
    The question is, why this latter is causing compilation errors?
    As already stated, you are getting errors because you edited line 2 of WTypes.h, which is apparent from the compiler output:
    Code:
    1>c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(2): error C2143: syntax error : missing ';' before 'constant'
    1>c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(1052): error C2371: 'CY' : redefinition; different basic types
    1> c:\program files\microsoft sdks\windows\v7.0a\include\wtypes.h(2) : see declaration of 'CY'
    Get a fresh copy of WTypes.h and try again with the unedited version.

    Mike

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center