From d07996d2ed95f125837b1577894a60855316eef9 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 17 Nov 2024 18:26:25 +1300 Subject: [PATCH] genbindings/headers: more detailed include guards, use pragma once --- cmd/genbindings/emitcabi.go | 5 +++-- libmiqt/libmiqt.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/genbindings/emitcabi.go b/cmd/genbindings/emitcabi.go index d4e9e8c4..7bbbfc32 100644 --- a/cmd/genbindings/emitcabi.go +++ b/cmd/genbindings/emitcabi.go @@ -609,7 +609,7 @@ func cabiPreventStructDeclaration(className string) bool { func emitBindingHeader(src *CppParsedHeader, filename string, packageName string) (string, error) { 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" @@ -617,7 +617,8 @@ func emitBindingHeader(src *CppParsedHeader, filename string, packageName string bindingInclude = "../" + bindingInclude } - ret.WriteString(`#ifndef ` + includeGuard + ` + ret.WriteString(`#pragma once +#ifndef ` + includeGuard + ` #define ` + includeGuard + ` #include diff --git a/libmiqt/libmiqt.h b/libmiqt/libmiqt.h index 8b6ddbc1..3b7b6767 100644 --- a/libmiqt/libmiqt.h +++ b/libmiqt/libmiqt.h @@ -1,5 +1,6 @@ -#ifndef MIQT_BINDING_H -#define MIQT_BINDING_H +#pragma once +#ifndef MIQT_LIBMIQT_LIBMIQT_H +#define MIQT_LIBMIQT_LIBMIQT_H #include #include