Skip to content

Functions which take Void as an argument cause the C++ compiler to error #1236

Description

@graysus
package;

class Main {
	public static function main():Void {
		var x:(Void)->Void = _ -> {
			// bad function
		}
	}
}

Compiling this code gives an error from the C++ compiler:

$ haxe --cpp out Main.hx
haxelib run hxcpp Build.xml haxe -Dhaxe="4.3.7" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.307" -Dhxcpp_api_level="430" -Dhxcpp_smart_strings="1" -Dsource_header="Generated by Haxe 4.3.7" -Dstatic="1" -Dtarget.atomics="1" -Dtarget.name="cpp" -Dtarget.static="1" -Dtarget.sys="1" -Dtarget.threaded="1" -Dtarget.unicode="1" -Dtarget.utf16="1" -Dutf16="1" -I -I/usr/share/haxe/std/cpp/_std/ -I/usr/share/haxe/std/
Creating /home/user/bug_report_hxcpp/out/obj/linux64/__pch/haxe/hxcpp.h.gch...

Compiling group: haxe
g++ -Iinclude -c -fvisibility=hidden -O2 -fpic -fPIC -Wno-overflow -DHX_LINUX -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=430(haxe) -m64 -DHXCPP_M64 -I/home/user/haxe/hxcpp/4,3,2/include ... tags=[haxe,static]
 - src/Main.cpp 
Error: ./src/Main.cpp: In static member function ‘static void Main_obj::main()’:
./src/Main.cpp:29:43: error: invalid use of type ‘void’ in parameter declaration
   29 |                         void _hx_run(void _){
      |                                      ~~~~~^

On other targets, this compiles without emitting an error.
I am using Linux, Haxe version 4.3.7, hxcpp version 4.3.2, and g++ version 15.1.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions