-
January 10th, 2023, 09:09 AM
#1
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
-
January 10th, 2023, 11:57 AM
#2
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.2)
-
January 17th, 2023, 09:58 AM
#3
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
-
January 30th, 2023, 06:52 AM
#4
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.
-
January 30th, 2023, 07:35 AM
#5
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.2)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|