ir: write declaration of global variable like struct fields
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
dfa6e5f982
commit
61e55ce4d9
@@ -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;
|
||||
@@ -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(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
@@ -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
|
||||
@@ -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];
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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];
|
||||
@@ -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
|
||||
@@ -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];
|
||||
Reference in New Issue
Block a user