GCC debugger stack trace displays wrong file name and line number

后端 未结 11 2037
说谎
说谎 2021-01-21 00:22

I am trying to port a fairly large C++ project to using g++ 4.0 on Mac OS X. My project compiles without errors, but I can\'t get GDB to work properly. When I look at the stack

11条回答
  •  耶瑟儿~
    2021-01-21 01:06

    I have a new thing you can try.

    Just before your own main you can write

    #ifdef main
    #  error main is defined
    #endif
    
    int main(int argc, char *argv[]) {
    

    this should give an error if you have some header that redefines main.

    If you define an own you might get an warning where a previous definition was made

    #define main foo
    
    int main(int argc, char *argv[]) {
    

    You can also try to undef just before your main

    #undef main
    
    int main(int argc, char *argv[]) {
    

提交回复
热议问题