Homebrew cctype error

TheMiningBoyAlpha

Well-Known Member
Newcomer
Joined
Apr 24, 2018
Messages
80
Reaction score
19
Trophies
0
Age
21
XP
384
Country
United States
I am trying to use TinyXML2 with my homebrew (for loading level data), and i keep getting errors with a few includes with TinyXML2.

In file included from C:/Users/TheMiningBoy/Documents/Roblox_DS/Game/source/main.c:12: C:/Users/TheMiningBoy/Documents/Roblox_DS/Game/include/tinyxml2.h:37:13: fatal error: cctype: No such file or directory 37 | # include <cctype> | ^~~~~~~~ compilation terminated. make[1]: *** [/opt/devkitpro/devkitARM/base_rules:85: main.o] Error 1 make: *** [Makefile:170: build] Error 2 Press any key to continue . . .

Can I have some help getting this to work?​
 
You're trying to include a C++ header from a C file. You should be able to either rename "main.c" to "main.cpp" if you're fine with changing to C++ or change "#include <cctype>" to "#include <ctype.h>". In C++ "<c[name]>" and "<[name].h>" headers are the same thing afaik, the "c[name]" style is more C++ style while "[name].h" is more C style, but in plain C you need the "[name].h" include.

Edit: Note: Changing the include may fix the problem of that include, but since it's trying to include a C++ header it's likely that that's C++ code you're trying to include which won't work if main() is in a C file, so you're probably better off changing main to a cpp file if you're trying to include other C++ code. It shouldn't require much if any code changes.
 
Last edited by Pk11,
You're trying to include a C++ header from a C file. You should be able to either rename "main.c" to "main.cpp" if you're fine with changing to C++ or change "#include <cctype>" to "#include <ctype.h>". In C++ "<c[name]>" and "<[name].h>" headers are the same thing afaik, the "c[name]" style is more C++ style while "[name].h" is more C style, but in plain C you need the "[name].h" include.
thanks, that fixed it, but now i need to find out how to load the xml files
 
It's possible to add C++ headers in C files (in fact, C and C++ compilers must link objects generated from either one, and are ensured to work):

headerFile.h
Code:
#ifndef __headerFile_h
#define __headerFile_h

#ifdef __cplusplus
extern "C" {
#endif

extern void func1(); //C++ linkage of C source files

#ifdef __cplusplus
extern class someClassName; //C++ linkage of C++ classes.
#endif

#ifdef __cplusplus
}
#endif

#endif //__headerFile_h end

Which means:
Even if this header is added inside a .c file (C source file),
first declaration will link objects from C into C++ (and viceversa -- very important to understand this), while also stripping out the next class declaration, being C++ only.

If you add this header into a .cpp file (C++ source file), both rules will apply and will link correctly.
 
Last edited by Coto,
It's possible to add C++ headers in C files (in fact, C and C++ compilers must link objects generated from either one, and are ensured to work):

headerFile.h
Code:
#ifndef __headerFile_h
#define __headerFile_h

#ifdef __cplusplus
extern "C" {
#endif

extern void func1(); //C++ linkage of C source files

#ifdef __cplusplus
extern class someClassName; //C++ linkage of C++ classes.
#endif

#ifdef __cplusplus
}
#endif

#endif //__headerFile_h end

Which means:
Even if this header is added inside a .c file (C source file),
first declaration will link objects from C into C++ (and viceversa -- very important to understand this), while also stripping out the next class declaration, being C++ only.

If you add this header into a .cpp file (C++ source file), both rules will apply and will link correctly.
i already fixed it
 

Site & Scene News

Popular threads in this forum