Supported data types passed between C and C++
C data type | Equivalent C++ data type |
---|---|
char | char |
signed char | signed char |
unsigned char | unsigned char |
short, signed short, short int, or signed short int | short, signed short, short int, or signed short int |
unsigned short, or unsigned short int | unsigned short, or unsigned short int |
int, signed, signed int | int, signed, signed int |
unsigned, or unsigned int | unsigned, or unsigned int |
long, signed long, long int, or signed long int | long, signed long, long int, or signed long int |
unsigned long, or unsigned long int | unsigned long, or unsigned long int |
float | float |
double | double |
long double | long double |
struct | struct, some classes |
union | union |
enum | enum |
array | array |
pointers to above types, pointers to void | pointers to above types, reference variables of above types, or pointers to void |
pointers to functions | pointers to functions |
types created by typedef | types created by typedef |
Note:
- C functions invoked from C++ or C++ functions invoked from C must be declared as
extern "C"
in the C++ source. - Packed decimal is not supported by C++. If you need to use packed decimal data, declare and modify it in C code using C functions.
- If C++ classes, using features that are not available in C (see Passing C++ objects for examples), are passed to C, the results are undefined.