The C code for HashLink, when generated from the following Haxe code, cannot be compiled with Visual Studio's C compiler, cl.exe. It works with MinGW's gcc (and gcc on macOS and Linux), though.
class HlcRestrict {
static function main() {
new HlcRestrict();
}
public function new() {
}
public var restrict:String;
}
Compiled with the following options:
--main HlcRestrict
--hl generated/HlcRestrict.c
cl.exe command in Visual Studio developer shell:
cl.exe /Ox /Fe:HlcRestrict.exe -I "<hashlink>\include" -I "generated" "generated/HlcRestrict.c" "<hashlink>\libhl.lib"
It results in the following error:
generated_std/HlcRestrict.h(22): error C2208: '_String *restrict ': no members defined using this type
Same result if you change it to _restrict or __restrict (one or two underscores).
public var _restrict:String;
public var __restrict:String;
However, if you change it to ___restrict with three underscores, cl.exe can successfully compile the generated C code:
public var ___restrict:String;
It looks like src/generators/hl2c.ml already has some code to rewrite certain field names when they conflict with C keywords, including restrict actually, but I guess that this behavior is specific to Visual Studio's C compiler that appears to have been missed.
The C code for HashLink, when generated from the following Haxe code, cannot be compiled with Visual Studio's C compiler, cl.exe. It works with MinGW's gcc (and gcc on macOS and Linux), though.
Compiled with the following options:
cl.exe command in Visual Studio developer shell:
It results in the following error:
Same result if you change it to
_restrictor__restrict(one or two underscores).However, if you change it to
___restrictwith three underscores, cl.exe can successfully compile the generated C code:It looks like src/generators/hl2c.ml already has some code to rewrite certain field names when they conflict with C keywords, including
restrictactually, but I guess that this behavior is specific to Visual Studio's C compiler that appears to have been missed.