Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] different method signatures for mingw and visual c

[SOLVED] different method signatures for mingw and visual c

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    You are missing a -D for your QMAKE_CFLAGS_DEBUG

    You could also simply use DEFINES += VISUAL_STUDIO

    Hope it helps

    PS: are you sure you want/need two set of function signatures ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tesmai4
      wrote on last edited by
      #3

      Thanks for your reply,

      I tried both of your suggestions, adding missing -D in flags and using DEFINES one after the other...

      It didn't help either way. I still get multiple definition error
      Where am I doing something wrong?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Without more information it becomes crystal ball guessing. You could be linking multiple libraries that provides the same function

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #5

          The function definition is likely to be in a header file that is being included in several different cpp files... but I am just guessing.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tesmai4
            wrote on last edited by
            #6

            Thanks for your reply.
            I only get this error after adding these two different function definitions.

            There is no error with @ static inline int FUNCA( Pkt_t *pkt )@

            I get multiple definition errors with this:
            @
            #ifdef VISUAL_STUDIO
            int FUNCA(
            #else
            static inline int FUNCA(
            #endif
            Pkt_t *pkt
            )
            @

            There is no other change in the program.

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #7

              Maybe you're including this header from two places only one of which sees the define so you get bot declarations?

              But why are you using your own define in the first place? There's a Qt one for this: Q_CC_MSVC and Q_CC_MINGW, or their underlying counterparts _MSC_VER and __MINGW32__. Try with one of those.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tesmai4
                wrote on last edited by
                #8

                Thanks, QT defined worked for me.

                What is wrong with custom defines? Why are these giving errors?

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  There's nothing wrong with user defines. There's probably something wrong with how you used them :) For example when you use one header in two statically linked libraries and the define differs in them.
                  But without seeing the whole setup you got it's as good as guessing.

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tesmai4
                    wrote on last edited by
                    #10

                    Following is my setup:
                    I define the DEFINES in QT project file like this;
                    @
                    DEFINES += VISUAL_STUDIO
                    @

                    Use this define in my header file
                    @#ifdef VISUAL_STUDIO
                    int FUNCA(
                    #else
                    static inline int FUNCA(
                    #endif
                    Pkt_t *pkt
                    )
                    @

                    Use this header file in one C file and in different header files.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      What Chris Kawa meant is:
                      Do you also make this define when using your header in other projects ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tesmai4
                        wrote on last edited by
                        #12

                        No, I am using this define only in this project.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          But your header is used in other projects ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            tesmai4
                            wrote on last edited by
                            #14

                            no. The header file is only used in this project.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              Project using sub-projects ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                ChrisW67
                                wrote on last edited by
                                #16

                                Do a complete clean build, i.e. delete all the intermediate files. If the error persists it would really help if you posted the full command that generated the error message and the full error message that followed verbatim (copy and paste, do not paraphrase). Usually the compiler error message tells you exactly where it thinks the earlier declaration occurred.

                                It would also help if you posted the few lines immediately following your ifdef-ed section. Since there is no semicolon of line 7 it is entirely possible that you are providing the function implementation rather than just declaring the function in the header: including that twice anywhere in your program will, as already pointed out, lead to this sort of error.

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved