Skip to content

<cstddef> not included, build fails #3

Description

@freultwah

Toolchain:

cc (Alpine 13.2.1_git20240309) 13.2.1 20240309
g++ (Alpine 13.2.1_git20240309) 13.2.1 20240309
GNU ld (GNU Binutils) 2.42
cmake version 3.29.3
ninja 1.9

On two occasions, the build process errored out with something like this:

 ./drain/Castable.h:613:31: error: 'nullptr_t' does not name a type
    613 |         bool operator==(const nullptr_t ptr) const {
        |                               ^~~~~~~~~
  ./drain/Castable.h:49:1: note: 'nullptr_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?

I took the liberty to patch it, and the build was successful:

diff --git a/src/drain/Castable.h b/src/drain/Castable.h
index 3c5f3a9..a4f7df5 100644
--- a/src/drain/Castable.h
+++ b/src/drain/Castable.h
@@ -46,6 +46,7 @@
 #include "Reference.h"
 #include "ValueScaling.h"
 #include "UniTuple.h"
+#include <cstddef>
@@ -611,7 +612,7 @@ class Castable {
 	/// Experimental. Notice that if type is set, false is returned also for an empty array.
 	/**
 	 *   Semantics..
 	 *   caster.ptr = nullptr : ?
 	 *   elementCount = 0 : ?
 	 */
 	inline
-	bool operator==(const nullptr_t ptr) const {
+	bool operator==(const std::nullptr_t ptr) const {
 		return getType() == typeid(void);
 	}

diff --git a/src/drain/util/Serializer.h b/src/drain/util/Serializer.h
index 51d41c6..7e6d0b9 100644
--- a/src/drain/util/Serializer.h
+++ b/src/drain/util/Serializer.h
@@ -32,6 +32,7 @@
 #include "drain/TypeUtils.h"
 #include "drain/StringBuilder.h"
+#include <cstddef>
@@ -188,7 +189,7 @@ class Serializer {
 		//return toStream(ostr, std::string("<null>")); // 2024/04
 		return toStream(ostr, TypeName<void>::name);
 	}
-	void toStream(std::ostream & ostr, const nullptr_t & t) const {
+	void toStream(std::ostream & ostr, const std::nullptr_t & t) const {
 		return toStream(ostr, "<null>");
 	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions