CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Compiling (formatting problem?)

    Code:
    #define OMWFMT64 L"I64"
    
    void
    integerToString(const OMByte* value, wchar_t* str)
    {
    	// Some stuff
    
    	std_swprintf(str, 21, L"%"OMWFMT64 L"u", *((OMUInt64*)value)); // <--- this line
    }
    The indicated line compiles fine with VS2005 but it fails to compile with VS2015 Community Edition, giving me these errors:-

    error C3688: invalid literal suffix 'OMWFMT64'; literal operator or literal operator template 'operator ""OMWFMT64' not found
    error C2664: 'int _snwprintf(wchar_t *,std::size_t,const wchar_t *,...)': cannot convert argument 3 from 'OMUInt64' to 'const wchar_t *'
    Does this make sense to anyone? Or have I discovered a bug in VS2015?

    It seems to be a problem with the #define because if I change the line to this, it does compile:-

    Code:
    	std_swprintf(str, 21, L"%I64" L"u", *((OMUInt64*)value));
    Last edited by John E; March 16th, 2017 at 12:18 PM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Compiling (formatting problem?)

    Maybe there's a problem with concatenation in VS2015 because inserting a space also fixes the problem. i.e. change from this

    Code:
    #define OMWFMT64 L"I64"
    
    std_swprintf(str, 21, L"%"OMWFMT64 L"u", *((OMUInt64*)value));
    to this

    Code:
    #define OMWFMT64 L"I64"
    
    std_swprintf(str, 21, L"%" OMWFMT64 L"u", *((OMUInt64*)value));
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiling (formatting problem?)

    with concatenation in VS2015
    Not a problem but a documented breaking change due to the introduction of user-defined literals.

    String literals followed by macros

    The compiler now supports user defined literals. As a consequence, string literals followed by macros without any intervening whitespace are interpreted as user-defined literals, which might produce errors or unexpected results.
    See https://msdn.microsoft.com/en-us/library/bb531344.aspx
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Compiling (formatting problem?)

    John, you might want to consider updating to the 2017 Community Edition. That way, you can resolve any breaking changes and be up to date with the current compiler.

  5. #5
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Compiling (formatting problem?)

    Thanks 2kaud, that makes sense now

    Arjay... I'm not nearly adventurous enough to be one of life's 'early adopters'!! I did migrate to VS2015 Community Edition (last year sometime) but I still remember how it would sometimes take 3-4 minutes to appear on screen, after clicking the icon (I assume it must have been updating from the internet maybe). I'm afraid I don't have much patience with stuff like that...
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiling (formatting problem?)

    You can have both VS2015 Community and VS2017 Community installed and both running on the same computer. I have VS2013, VS2015 and VS2017 installed. Also note that from the installed latest version if you previous versions installed you can compile for that version (Properties/General/Platform toolset). ie On my system from VS2017 I can compile for 13, 15 and 17. Try VS2017, you have nothing to loose (just some disk space!).

    how it would sometimes take 3-4 minutes to appear on screen
    VS2015 start-up is very disk intensive - so if you have a slow disk..... This has been improved with VS2017.

    Improved startup and improved project load. Multiple enhancements come together to make Visual Studio 2017 start up faster than Visual Studio 2015. Solution load times are shorter, and build performance is faster, particularly for C++ projects
    See https://blogs.msdn.microsoft.com/vis...-and-partners/
    Last edited by 2kaud; March 17th, 2017 at 03:59 PM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

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