c2v
c2v copied to clipboard
It seems NULL is not recognized: error: use of undeclared identifier 'NULL'
Hi, the error pops-up in framework.h of this GitHub package: OC I thought I mention it as (I think...) NULL is part of the C standard... Here the code:
#define _oc_framework(FRAMEWORK)\
static void* FRAMEWORK = NULL;\
_oc_extern_c_begin\
__attribute__((constructor)) static inline void\
_oc_framework_initializer_##FRAMEWORK(void) {\
const char path[] = #FRAMEWORK".framework/"#FRAMEWORK;\
__oc_framework_initializer(&FRAMEWORK, path);\
}\
_oc_extern_c_end
_oc_extern_c_begin
static inline void
__oc_framework_initializer(void** pframework, const char path[]) {
assert(*pframework == NULL);
enum { RTLD_LAZY_LOCAL = 0x1 | 0x4 };
extern void* dlopen(const char*,int);
*pframework = dlopen(path, RTLD_LAZY_LOCAL);
assert(*pframework);
}
_oc_extern_c_end
The aforementioned package has only a handful of header files, and even after fixing the NULL error with '#define NULL 0` c2v stumbles.
Maybe because this package is actually a bunch of sophisticated C macros, it will be hard to let c2v convert it to V, especially because (depending on the code where these macros are used) the macros get expanded differently.
Thanks
Actually, NULL is (almost?) always a macro, not part of the language.
I think you are correct. Wikipedia says it can be "portably" defined as : ((void *)0)
So, in the end it's up to the C2V maintainers if they want to define it automatically or not...
It would be nice if these few header files of the OC package could be transpiled...