Homebrew cctype error

TheMiningBoyAlpha

Well-Known Member
OP
Newcomer
Joined
Apr 24, 2018
Messages
80
Trophies
0
Age
19
XP
360
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?​
 

Pk11

A catgirl with a DSi
Member
Joined
Jun 26, 2019
Messages
1,285
Trophies
1
Age
22
Location
米国
Website
xn--rck9c.xn--tckwe
XP
3,902
Country
United States
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,

TheMiningBoyAlpha

Well-Known Member
OP
Newcomer
Joined
Apr 24, 2018
Messages
80
Trophies
0
Age
19
XP
360
Country
United States
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
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
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,

TheMiningBoyAlpha

Well-Known Member
OP
Newcomer
Joined
Apr 24, 2018
Messages
80
Trophies
0
Age
19
XP
360
Country
United States
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

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    Go gay there I made up his mind
  • AncientBoi @ AncientBoi:
    :rofl2::tpi::rofl2: I meant his eyes :tpi::rofl2::tpi:
  • ZeroT21 @ ZeroT21:
    :toot:blow me then @K3Nv2
  • K3Nv2 @ K3Nv2:
    Nah I'm straight but you're more than welcome to blow ancientboi
  • ZeroT21 @ ZeroT21:
    LOL, which straight person does not make gay jokes?
    +1
  • K3Nv2 @ K3Nv2:
    I'm straight but we can whack dicks together
  • ZeroT21 @ ZeroT21:
    nah, I'm gud over here, no need for sword fights

    :glare:
    +1
  • K3Nv2 @ K3Nv2:
    Dick slang
  • K3Nv2 @ K3Nv2:
    See ancientboi already has a crush on you
  • AncientBoi @ AncientBoi:
    [brings my ⚔️ ] On Guard :D:evil::wub:
  • K3Nv2 @ K3Nv2:
    Looks more like a dagger to me
  • AncientBoi @ AncientBoi:
    Pffffft I have a crush on everybody
  • ZeroT21 @ ZeroT21:
    I see no problem, unless i happen to grow another gender one day. Too bad it ain't now
  • K3Nv2 @ K3Nv2:
    Thought you already had both hotswappable gender fluid
  • ZeroT21 @ ZeroT21:
    Enjoy whatever life chucks your way

    :teach:
    +1
  • K3Nv2 @ K3Nv2:
    Deeze nuts
  • AncientBoi @ AncientBoi:
    Dem Nutz
  • ZeroT21 @ ZeroT21:
    'Em nutters
  • AncientBoi @ AncientBoi:
    M&M nutz
    +1
  • K3Nv2 @ K3Nv2:
    Slim anus nutter
  • AncientBoi @ AncientBoi:
    :unsure::unsure::unsure: I might go buy them M&M w/nuts. I gotta go out to pay the rent anyway
    +2
  • Psionic Roshambo @ Psionic Roshambo:
    Eat a Snickers!
    Psionic Roshambo @ Psionic Roshambo: Eat a Snickers!