Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/bindgen/ir/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::io::Write;

use syn;

use crate::bindgen::cdecl;
use crate::bindgen::config::Config;
use crate::bindgen::declarationtyperesolver::DeclarationTypeResolver;
use crate::bindgen::dependencies::Dependencies;
Expand Down Expand Up @@ -112,7 +113,7 @@ impl Source for Static {
} else if !self.mutable {
out.write("const ");
}
self.ty.write(config, out);
write!(out, " {};", self.export_name());
cdecl::write_field(out, &self.ty, &self.export_name, config);
out.write(";");
}
}
8 changes: 8 additions & 0 deletions tests/expectations/both/global_variable.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];
16 changes: 16 additions & 0 deletions tests/expectations/both/global_variable.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
8 changes: 8 additions & 0 deletions tests/expectations/global_variable.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];
16 changes: 16 additions & 0 deletions tests/expectations/global_variable.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
12 changes: 12 additions & 0 deletions tests/expectations/global_variable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>

extern "C" {

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];

} // extern "C"
8 changes: 8 additions & 0 deletions tests/expectations/tag/global_variable.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];
16 changes: 16 additions & 0 deletions tests/expectations/tag/global_variable.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

extern const char CONST_GLOBAL_ARRAY[128];

extern char MUT_GLOBAL_ARRAY[128];

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
5 changes: 5 additions & 0 deletions tests/rust/global_variable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[no_mangle]
pub static mut MUT_GLOBAL_ARRAY: [c_char; 128] = [0; 128];

#[no_mangle]
pub static CONST_GLOBAL_ARRAY: [c_char; 128] = [0; 128];