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

    What's the new style declaration ?

    Trying to build this code in VS2019 gives me Error C2447 '{': missing function header (old-style formal list?) :-

    Code:
    static __cdecl void
    unload_custom_fonts()
    {
    	std::string font_file;
    	if (find_file (ardour_data_search_path(), "ArdourMono.ttf", font_file)) {
    		RemoveFontResource(font_file.c_str());
    	}
    	if (find_file (ardour_data_search_path(), "ArdourSans.ttf", font_file)) {
    		RemoveFontResource(font_file.c_str());
    	}
    }
    I can eliminate the error by removing the __cdecl bit - though presumably that's needed? I'm building as 64-bit and I've a vague recollection that all functions are cdecl now so will it be okay just to remove it? (it's possible that others might be building as 32-bit)
    "A problem well stated is a problem half solved.” - Charles F. Kettering

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

    Re: What's the new style declaration ?

    __cdecl goes after the return type and before the function name for VS.
    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)

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

    Re: What's the new style declaration ?

    Thanks for the reply 2kaud and sorry for the delay - I keep forgetting that this forum won't send notifications any more.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #4
    Join Date
    Jan 2023
    Posts
    1

    Re: What's the new style declaration ?

    C++11 introduced a new way to declare variables known as "uniform initialization" or "uniform initializer syntax." This syntax provides a more concise and consistent way to initialize objects, and can also help prevent certain types of programming errors.

    The new syntax uses curly braces {} to specify the initial value, instead of parentheses ():

    java

    // Old style initialization
    int x(0);

    // New style initialization
    int x{0};
    This syntax works with any type of object, including built-in types, user-defined types, and objects created with dynamic allocation. The exact behavior of this syntax depends on the type of object being initialized.

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

    Re: What's the new style declaration ?

    Yes - but the OP was regarding usage of __cdecl
    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