Skip to content

Commit fcf0d1f

Browse files
authored
Merge pull request #100 from robertgoss/CrossComponentInheritance_msvc_warning
## Issues - #99 ## Symptom When compiling the c++ act bindings for a cross component interface project the visual studio compiler outputs warningsof the form: ``` typedef struct { PAbstractCAMBase_GetLastErrorPtr m_Base_GetLastError; PAbstractCAMBase_ReleaseInstancePtr m_Base_ReleaseInstance; PAbstractCAMBase_AcquireInstancePtr m_Base_AcquireInstance; PAbstractCAMBase_GetVersionPtr m_Base_GetVersion; PAbstractCAMBase_GetSymbolLookupMethodPtr m_Base_GetSymbolLookupMethod; } sAbstractCAMFunctionTableBase; typedef struct : sAbstractCAMFunctionTableBase { PAbstractCAMLinking_CreateLinkerPtr m_Linking_CreateLinker; PAbstractCAMLinking_QueryStrategyPtr m_Linking_QueryStrategy; } sAbstractCAMFunctionTableLinking; ``` ## Problem This appars to be the issue in https://developercommunity.visualstudio.com/content/problem/1034754/warning-c5208-a-c20-feature-occurs-when-compiling-1.html In particular we define anonymous structs with member that are then typedefed ## Solution We give a name to the function table structs based on the typedef name with "Struct" appended to make it unique. ## Verification Recompiled bindings after the change with no warning. Tests to call the interface still pass.
2 parents 2ac44b8 + b806aa7 commit fcf0d1f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Source/buildbindingccpp.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func buildDynamicCCPPHeader(component ComponentDefinition, w LanguageWriter, Nam
246246
w.Writeln(" Function Table Structure")
247247
w.Writeln("**************************************************************************************************************************/")
248248
w.Writeln("")
249-
w.Writeln("typedef struct {")
249+
w.Writeln("typedef struct s%sDynamicWrapperTableStruct {", NameSpace)
250250
w.Writeln(" void * m_LibraryHandle;")
251251

252252
for i := 0; i < len(component.Classes); i++ {
@@ -267,22 +267,24 @@ func buildDynamicCCPPHeader(component ComponentDefinition, w LanguageWriter, Nam
267267

268268
for i := 0; i < len(component.Classes); i++ {
269269
class := component.Classes[i]
270+
structName := fmt.Sprintf("s%sFunctionTable%sStruct", NameSpace, class.ClassName)
271+
typedefName := fmt.Sprintf("s%sFunctionTable%s", NameSpace, class.ClassName)
270272
if len(class.ParentClass) > 0 {
271273
paramNameSpace, paramClassName, _ := decomposeParamClassName(class.ParentClass)
272274
if len(paramNameSpace) == 0 {
273-
w.Writeln("typedef struct : s%sFunctionTable%s {", NameSpace, class.ParentClass)
275+
w.Writeln("typedef struct %s : s%sFunctionTable%s {", structName, NameSpace, class.ParentClass)
274276
} else {
275-
w.Writeln("typedef struct : s%sFunctionTable%s {", component.ImportedComponentDefinitions[paramNameSpace].NameSpace, paramClassName)
277+
w.Writeln("typedef struct %s : s%sFunctionTable%s {", structName, component.ImportedComponentDefinitions[paramNameSpace].NameSpace, paramClassName)
276278
}
277279
} else {
278-
w.Writeln("typedef struct {")
280+
w.Writeln("typedef struct %s {", structName)
279281
}
280282

281283
for j := 0; j < len(class.Methods); j++ {
282284
method := class.Methods[j]
283285
w.Writeln(" P%s%s_%sPtr m_%s_%s;", NameSpace, class.ClassName, method.MethodName, class.ClassName, method.MethodName)
284286
}
285-
w.Writeln("} s%sFunctionTable%s;", NameSpace, class.ClassName)
287+
w.Writeln("} %s;", typedefName)
286288
w.Writeln("")
287289
}
288290

0 commit comments

Comments
 (0)