godotengine / godotengine/godot-cpp

Using memnew to create a Node that has more than one constructor parameter fails when using an initialiser list.

Open
#1,274 15 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

v4.1.1.stable.custom_build [bd6af8e0e]

### godot-cpp version

4.1 4eed2d7be017ef06521665604990114c9fff7c77

### System information

Godot v4.1.1.stable (bd6af8e0e) - Linux Mint 21.2 (Victoria) - Vulkan (Forward+) - integrated Intel(R) Graphics (RPL-P) () - 13th Gen Intel(R) Core(TM) i7-1360P (16 Threads)

### Issue description

When creating a `::godot::Node` we should use `memnew` instead of `new`. I have made a subclass of `Node3D` that has two constructor parameters. I tried to create an instance with

memnew (MySubclassOfNode3D {x, y})

This fails, because `memnew` is a macro, and to the C++ preprocessor this is a macro call with two arguments, rather than one.

I previously reported this issue here: https://godotforums.org/d/36888-using-memnew-to-create-a-node-that-has-two-constructor-parameters

### Steps to reproduce

Create a subclass of `Node3D` with more than one constructor parameter and create an instance with `memnew`.

### Minimal reproduction project

N/A

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.