BOOL bool ? unresolved external symbol

This is a discussion on BOOL bool ? unresolved external symbol within the C Programming forums, part of the General Programming Boards category; All I did was add the following two lines to my mysql.h file: Code: #include ".\mysql\h\my_global.h" #include ".\mysql\h\m_string.h" Everything compiled ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    55

    Question BOOL bool ? unresolved external symbol

    All I did was add the following two lines to my mysql.h file:
    Code:
    #include ".\mysql\h\my_global.h"
    #include ".\mysql\h\m_string.h"
    Everything compiled great until the very end.

    Then I got these errors:
    Code:
    1>Linking...
    1>item_handling.obj : error LNK2019: unresolved external symbol "void __cdecl affect_join(struct playerDATA *,struct affected_type *,bool,bool,bool,bool)" (?affect_join@@YAXPAUplayerDATA@@PAUaffected_type@@_N222@Z) referenced in function "void __cdecl do_drink(struct playerDATA *,char *,int,int)" (?do_drink@@YAXPAUplayerDATA@@PADHH@Z)
    1>verb_eat.obj : error LNK2001: unresolved external symbol "void __cdecl affect_join(struct playerDATA *,struct affected_type *,bool,bool,bool,bool)" (?affect_join@@YAXPAUplayerDATA@@PAUaffected_type@@_N222@Z)
    1>utilities_one.obj : error LNK2019: unresolved external symbol "void __cdecl affect_join7z(struct playerDATA *,struct affected_type7z *,bool,bool,bool,bool)" (?affect_join7z@@YAXPAUplayerDATA@@PAUaffected_type7z@@_N222@Z) referenced in function "void __cdecl apply_roundtime(int,int,struct playerDATA *,int,int,unsigned long)" (?apply_roundtime@@YAXHHPAUplayerDATA@@HHK@Z)
    1>utilities_one.obj : error LNK2019: unresolved external symbol "void __cdecl affect_join5z(struct playerDATA *,struct affected_type5z *,bool)" (?affect_join5z@@YAXPAUplayerDATA@@PAUaffected_type5z@@_N@Z) referenced in function "void __cdecl apply_roundtime(int,int,struct playerDATA *,int,int,unsigned long)" (?apply_roundtime@@YAXHHPAUplayerDATA@@HHK@Z)
    1>XIAIX.exe : fatal error LNK1120: 3 unresolved externals
    Just for grins and giggles, I changed:
    Code:
    void affect_join(struct playerDATA *ch, struct affected_type *af, bool add_dur, bool avg_dur, bool add_mod, bool avg_mod);
    void affect_join5z(struct playerDATA *ch, struct affected_type5z *af5z, bool add_dur);
    void affect_join7z(struct playerDATA *ch, struct affected_type7z *af7z, bool add_dur, bool avg_dur, bool add_mod, bool avg_mod);
    to

    Code:
    void affect_join(struct playerDATA *ch, struct affected_type *af);
    void affect_join5z(struct playerDATA *ch, struct affected_type5z *af5z);
    void affect_join7z(struct playerDATA *ch, struct affected_type7z *af7z);
    (as you can see I only left out the bool values) and presto, everything compiled fine with no errors.

    Now, I know you're bored already from reading all this pucky stuff but I promise, I'm almost done.

    Okay, in the "my_global.h" file there's another #include to the "config-win.h" file. Within that "config-win.h" file there's a line of code, it reads:
    Code:
    #define bool BOOL
    I commented this line of code out and the whole program compiles just fine now with no errors or warnings.

    SO, MY QUESTION IS THIS:

    Does anyone see any ill side effects from me commenting out this line? Something that I might run into in the future?

    tyia

  2. #2
    Banned
    Join Date
    May 2008
    Location
    Four Dots Planet
    Posts
    72
    well windows have there own BOOL for c so the author may be wanted to use that

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    No, actually, in C there is no "bool," so the define was there to make bool default as BOOL, so you can use "bool" just as well as "BOOL".
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    There is a macro bool in C99 in stdbool.h which evaluates to _Bool.

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Your changing of function prototypes is probably going to cause errors, if you ever tried to use those functions.

    First, I'd check that you have the latest version - this might have been fixed. If you do/it hasn't, then I would create a "wrapper" header that includes the MySQL headers (the original ones, before you made changes) that you need, and then undef's bool. Additionally, when you were compiling, you got linker errors, that included C++ name mangling. All in all, what I'd try might be something like:
    Code:
    #ifndef FIX_MYSQL_H
    #define FIX_MYSQL_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include ".\mysql\h\my_global.h"
    #include ".\mysql\h\m_string.h"
    #ifdef bool
    #undef bool
    #endif
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    Do you really need the #ifdef bool, though? Wouldn't simply #undef suffice?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    53
    Quote Originally Posted by Cactus_Hugger View Post
    Your changing of function prototypes is probably going to cause errors, if you ever tried to use those functions.
    Wow, that's a nice euphemism :-)

    xwielder, note that C linking just looks up the symbol; there is no name mangling and no parameter checking. If you do something like the following:

    impl.c
    Code:
    int square(int x)
    {
        return x*x;
    }
    main.c
    Code:
    int square(void);
    int main(void)
    {
        int y = square();
        return 0;
    }
    then this will compile and link without errors; the implementation of square() will simply grab whatever is on the stack (or in a certain register, depending on your system) and use it as if it were a caller-supplied value for x.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 02:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21