-
Notifications
You must be signed in to change notification settings - Fork 967
Document C2323 #4993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document C2323 #4993
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "Compiler Error C2323" | ||
description: "Learn more about: Compiler Error C2323" | ||
ms.date: "03/20/2024" | ||
f1_keywords: ["C2323"] | ||
helpviewer_keywords: ["C2323"] | ||
--- | ||
# Compiler Error C2323 | ||
|
||
'identifier': non-member operator `new` or `delete` functions may not be declared `static` or in a namespace other than the global namespace. | ||
|
||
The `new` and `delete` overload operators must be non-static, defined in the global namespace or as class members. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be more precise it should be "operator overloads" and not "overload operators". In addition, with the placement of the comma, one possible misinterpretation of the sentence is that I will address these issues in a follow-up PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's cool. It was just a bit verbose before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can split it into 2 lines, one for the case where it is in the global namespace (emphasis on must be non-static), and the other is for class members (emphasis on optional There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea |
||
|
||
The following generates C2323: | ||
|
||
```cpp | ||
// C2323.cpp | ||
// compile with: /c | ||
static void* operator new(size_t); // C2323 since static | ||
static void operator delete(void*); // C2323 since static | ||
|
||
namespace NS | ||
{ | ||
void* operator new(size_t); // C2323 since not defined in the global namespace | ||
void operator delete(void*); // C2323 since not defined in the global namespace | ||
} | ||
``` | ||
|
||
## See also | ||
|
||
[`new` and `delete` operators](../../cpp/new-and-delete-operators.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should keywords in error messages have backticks or be shown verbatim (raw with no backticks)? Since what I commonly see is the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to prevent machine translation. We weren't good about this and got complaints about crazy machine translations for things that shouldn't be translated in the first place. So, we started adding the back ticks.