Core: Modernize C headers with C++ equivalents

This commit is contained in:
Thaddeus Crews
2025-04-28 16:05:13 -05:00
parent a8ece29adc
commit 01fc9aee6c
101 changed files with 126 additions and 168 deletions

View File

@@ -43,8 +43,6 @@
#include "core/variant/variant.h"
#include "core/version.h"
#include <string.h>
class CallableCustomExtension : public CallableCustom {
void *userdata;
void *token;

View File

@@ -34,15 +34,16 @@
* Together with the JSON file, you should be able to generate any binder.
*/
#ifndef __cplusplus
#include <stddef.h>
#include <stdint.h>
#ifndef __cplusplus
typedef uint32_t char32_t;
typedef uint16_t char16_t;
#endif
#else
#include <cstddef>
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -34,8 +34,6 @@ IPAddress::operator Variant() const {
return operator String();
}*/
#include <string.h>
IPAddress::operator String() const {
if (wildcard) {
return "*";

View File

@@ -35,7 +35,7 @@
#include "core/string/ustring.h"
#include "core/templates/vector.h"
#include <stdarg.h>
#include <cstdarg>
class RegEx;

View File

@@ -35,8 +35,8 @@
#include "core/object/script_language.h"
#include "core/variant/container_type_validate.h"
#include <limits.h>
#include <stdio.h>
#include <climits>
#include <cstdio>
void EncodedObjectAsID::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);

View File

@@ -43,7 +43,8 @@
#include "core/math/vector3.h"
#include "core/templates/local_vector.h"
#include "core/templates/pooled_list.h"
#include <limits.h>
#include <climits>
#define BVHABB_CLASS BVH_ABB<BOUNDS, POINT>

View File

@@ -88,7 +88,7 @@ subject to the following restrictions:
#endif
#if defined(DEBUG_CONVEX_HULL) || defined(SHOW_ITERATIONS)
#include <stdio.h>
#include <cstdio>
#endif
// Convex hull implementation based on Preparata and Hong

View File

@@ -34,7 +34,7 @@
#include "core/object/class_db.h"
#include "core/object/script_language.h"
#include <stdio.h>
#include <cstdio>
#ifdef DEV_ENABLED
// Includes safety checks to ensure that a queue set as a thread singleton override

View File

@@ -32,8 +32,7 @@
#include "core/templates/safe_refcount.h"
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
void *operator new(size_t p_size, const char *p_description) {
return Memory::alloc_static(p_size, false);

View File

@@ -33,7 +33,6 @@
#include "core/error/error_macros.h"
#include "core/templates/safe_refcount.h"
#include <cstring>
#include <new> // IWYU pragma: keep // `new` operators.
#include <type_traits>

View File

@@ -37,7 +37,7 @@
#include "core/os/midi_driver.h"
#include "core/version_generated.gen.h"
#include <stdarg.h>
#include <cstdarg>
#ifdef MINGW_ENABLED
#define MINGW_STDTHREAD_REDUNDANCY_WARNING

View File

@@ -38,7 +38,7 @@
#include "core/templates/list.h"
#include "core/templates/vector.h"
#include <stdlib.h>
#include <cstdlib>
class OS {
static OS *singleton;

View File

@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "time.h"
#include "time.h" // NOLINT(modernize-deprecated-headers) False positive with C-Header of the same name.
#include "core/os/os.h"

View File

@@ -30,8 +30,6 @@
#include "string_builder.h"
#include <string.h>
StringBuilder &StringBuilder::append(const String &p_string) {
if (p_string.is_empty()) {
return *this;

View File

@@ -35,7 +35,6 @@
#include "core/templates/safe_refcount.h"
#include "core/templates/span.h"
#include <string.h>
#include <initializer_list>
#include <type_traits>

View File

@@ -37,7 +37,7 @@
#include "core/templates/rid.h"
#include "core/templates/safe_refcount.h"
#include <stdio.h>
#include <cstdio>
#include <typeinfo> // IWYU pragma: keep // Used in macro.
#ifdef SANITIZERS_ENABLED

View File

@@ -50,6 +50,7 @@ static_assert(__cplusplus >= 201703L, "Minimum of C++17 required.");
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <utility>
// IWYU pragma: end_exports

View File

@@ -40,7 +40,7 @@
#include "core/variant/variant.h"
#include "core/variant/variant_internal.h"
#include <stdio.h>
#include <cstdio>
// Variant cannot define an implicit cast operator for every Object subclass, so the
// casting is done here, to allow binding methods with parameters more specific than Object *

View File

@@ -32,7 +32,7 @@
#include "core/version_generated.gen.h" // IWYU pragma: export
#include <stdint.h>
#include <stdint.h> // NOLINT(modernize-deprecated-headers) FIXME: MinGW compilation fails when changing to C++ Header.
// Copied from typedefs.h to stay lean.
#ifndef _STR