When the MySQL header file is directly referenced in the C ++ code, the following error may occur:
In file encoded ded from/usr/include/C ++/4.1.0/bits/char_traits.h: 46,
From/usr/include/C ++/4.1.0/string: 46,
/Usr/include/C ++/4.1.0/bits/stl_algobase.h: 92: 28: Error: Macro "Swap" requires 3 arguments, but only 2 given
/Usr/include/C ++/4.1.0/bits/stl_algobase.h: 127: 26: Error: Macro "Swap" requires 3 arguments, but only 2 given
/Usr/include/C ++/4.1.0/bits/vector. TCC: 176: 20: Error: Macro "Swap" requires 3 arguments, but only 1 given
/Usr/include/C ++/4.1.0/cctype: 70: Error: ': isalnum' has not been declared
/Usr/include/C ++/4.1.0/cctype: 71: Error: ': isalpha' has not been declared
/Usr/include/C ++/4.1.0/cctype: 72: Error: ': iscntrl' has not been declared
/Usr/include/C ++/4.1.0/cctype: 73: Error: ': isdigit' has not been declared
/Usr/include/C ++/4.1.0/cctype: 74: Error: ': isgraph' has not been declared
/Usr/include/C ++/4.1.0/cctype: 75: Error: ': islower' has not been declared
/Usr/include/C ++/4.1.0/cctype: 76: Error: ': isprint' has not been declared
/Usr/include/C ++/4.1.0/cctype: 77: Error: ': ispunct' has not been declared
/Usr/include/C ++/4.1.0/cctype: 78: Error: ': isspace' has not been declared
/Usr/include/C ++/4.1.0/cctype: 79: Error: ': isupper' has not been declared
/Usr/include/C ++/4.1.0/cctype: 80: Error: ': isxdigit' has not been declared
/Usr/include/C ++/4.1.0/cctype: 81: Error: ': tolower' has not been declared
/Usr/include/C ++/4.1.0/cctype: 82: Error: ': toupper' has not been declared
Solution:
Try to wrap MySQL twice so that the caller cannot see the MySQL header file, for example, including in CPP:
# Include <my_global.h>
# Include <my_sys.h>
# Include <mysql. h>
Only the following statements can be referenced in the header file:
Struct st_mysql;
Struct st_mysql_res;
Typedef long num_t;
Typedef char ** mysql_row;/** return data as array of strings */
Do not include the header file directly to the MySQL header file, and ensure that only the MySQL file is included in one CPP file. Otherwise, you may encounter many inexplicable compilation errors. If you do not think of this, the error cause may not be found even if it takes one day.
Supplement: Mysql4.x and mysql5.x header files are not compatible, preferably version 5.xSupplement: Some versions can only reference # include <mysql. h>. Otherwise, a file error in the C ++ standard library is reported. The original post is posted on my Forum: |
Http://bbs.hadoopor.com/thread-1564-1-1.html