mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Generate extern "C" in the .c, not just the .h.
This commit is contained in:
1 parent
71a3ad6563
commit
cc9aeb63c1
2 files changed
+15
-11
No files matched your search
@@ -26,10 +26,7 @@ func (g *Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byt
|
|||||||
// Write preamble.
|
// Write preamble.
|
||||||
fmt.Fprintf(b, "// Code generated by puffs-gen-%c. DO NOT EDIT.\n\n", g.Extension)
|
fmt.Fprintf(b, "// Code generated by puffs-gen-%c. DO NOT EDIT.\n\n", g.Extension)
|
||||||
b.WriteString(preamble)
|
b.WriteString(preamble)
|
||||||
b.WriteByte('\n')
|
b.WriteString("\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n")
|
||||||
if g.Extension == 'h' {
|
|
||||||
b.WriteString("#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
b.WriteString("// ---------------- Status Codes\n\n")
|
b.WriteString("// ---------------- Status Codes\n\n")
|
||||||
b.WriteString("typedef enum {\n")
|
b.WriteString("typedef enum {\n")
|
||||||
@@ -60,7 +57,12 @@ func (g *Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.Extension != 'h' {
|
// Finish up the header, which is also the first part of the .c file.
|
||||||
|
b.WriteString("\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n")
|
||||||
|
if g.Extension == 'h' {
|
||||||
|
return format(b)
|
||||||
|
}
|
||||||
|
|
||||||
b.WriteString("// ---------------- Constructor and Destructor Implementations\n\n")
|
b.WriteString("// ---------------- Constructor and Destructor Implementations\n\n")
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
for _, n := range f.TopLevelDecls() {
|
for _, n := range f.TopLevelDecls() {
|
||||||
@@ -71,12 +73,6 @@ func (g *Generator) Generate(pkgName string, m *t.IDMap, files []*a.File) ([]byt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Write postamble.
|
|
||||||
if g.Extension == 'h' {
|
|
||||||
b.WriteString("\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
return format(b)
|
return format(b)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
#error "Puffs requires a word size of at least 32 bits"
|
#error "Puffs requires a word size of at least 32 bits"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------- Status Codes
|
// ---------------- Status Codes
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -39,6 +43,10 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self);
|
|||||||
|
|
||||||
void puffs_gif_lzw_decoder_destructor(puffs_gif_lzw_decoder* self);
|
void puffs_gif_lzw_decoder_destructor(puffs_gif_lzw_decoder* self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ---------------- Constructor and Destructor Implementations
|
// ---------------- Constructor and Destructor Implementations
|
||||||
|
|
||||||
void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self) {
|
void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self) {
|
||||||
|
|||||||
Reference in new issue
Block a user