genbindings/headers: more detailed include guards, use pragma once

This commit is contained in:
mappu 2024-11-17 18:26:25 +13:00
parent 2d665dd840
commit d07996d2ed
2 changed files with 6 additions and 4 deletions

View File

@ -609,7 +609,7 @@ func cabiPreventStructDeclaration(className string) bool {
func emitBindingHeader(src *CppParsedHeader, filename string, packageName string) (string, error) { func emitBindingHeader(src *CppParsedHeader, filename string, packageName string) (string, error) {
ret := strings.Builder{} ret := strings.Builder{}
includeGuard := "GEN_" + strings.ToUpper(strings.Replace(strings.Replace(filename, `.`, `_`, -1), `-`, `_`, -1)) includeGuard := "MIQT_" + strings.ToUpper(strings.Replace(strings.Replace(packageName, `/`, `_`, -1), `-`, `_`, -1)) + "_GEN_" + strings.ToUpper(strings.Replace(strings.Replace(filename, `.`, `_`, -1), `-`, `_`, -1))
bindingInclude := "../libmiqt/libmiqt.h" bindingInclude := "../libmiqt/libmiqt.h"
@ -617,7 +617,8 @@ func emitBindingHeader(src *CppParsedHeader, filename string, packageName string
bindingInclude = "../" + bindingInclude bindingInclude = "../" + bindingInclude
} }
ret.WriteString(`#ifndef ` + includeGuard + ` ret.WriteString(`#pragma once
#ifndef ` + includeGuard + `
#define ` + includeGuard + ` #define ` + includeGuard + `
#include <stdbool.h> #include <stdbool.h>

View File

@ -1,5 +1,6 @@
#ifndef MIQT_BINDING_H #pragma once
#define MIQT_BINDING_H #ifndef MIQT_LIBMIQT_LIBMIQT_H
#define MIQT_LIBMIQT_LIBMIQT_H
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>