diff --git a/Sources/backends/hlsl.c b/Sources/backends/hlsl.c index de22c3c..86b5ae0 100644 --- a/Sources/backends/hlsl.c +++ b/Sources/backends/hlsl.c @@ -55,10 +55,26 @@ static void write_bytecode(char *hlsl, char *directory, const char *filename, co { sprintf(full_filename, "%s/%s.h", directory, filename); FILE *file = fopen(full_filename, "wb"); + + fprintf(file, "#ifndef KONG_%s_HEADER\n", name); + fprintf(file, "#define KONG_%s_HEADER\n\n", name); + fprintf(file, "#include \n"); fprintf(file, "#include \n\n"); + + fprintf(file, "#ifdef __cplusplus\n"); + fprintf(file, "extern \"C\" {\n"); + fprintf(file, "#endif\n\n"); + fprintf(file, "extern uint8_t *%s;\n", name); fprintf(file, "extern size_t %s_size;\n", name); + + fprintf(file, "\n#ifdef __cplusplus\n"); + fprintf(file, "}\n"); + fprintf(file, "#endif\n\n"); + + fprintf(file, "#endif\n"); + fclose(file); } diff --git a/Sources/integrations/kope.c b/Sources/integrations/kope.c index 876fe0d..0a69b30 100644 --- a/Sources/integrations/kope.c +++ b/Sources/integrations/kope.c @@ -293,6 +293,10 @@ void kope_export(char *directory, api_kind api) { fprintf(output, "#include \n"); fprintf(output, "#include \n\n"); + fprintf(output, "#ifdef __cplusplus\n"); + fprintf(output, "extern \"C\" {\n"); + fprintf(output, "#endif\n"); + fprintf(output, "\nvoid kong_init(kope_g5_device *device);\n\n"); for (global_id i = 0; get_global(i) != NULL && get_global(i)->type != NO_TYPE; ++i) { @@ -437,6 +441,10 @@ void kope_export(char *directory, api_kind api) { } } + fprintf(output, "#ifdef __cplusplus\n"); + fprintf(output, "}\n"); + fprintf(output, "#endif\n\n"); + fprintf(output, "#endif\n"); fclose(output);