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. C++ <complex> yielding strange behavior
Forum Updated to NodeBB v4.3 + New Features

C++ <complex> yielding strange behavior

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 2.9k Views 3 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #4

    Thanks for the replies, guys. The problem was indeed linked to a filename confusion. I renamed the project to "complex_test" and it worked just fine. You see something new every day...

    kshegunov: I was using a shadow build, so I didn't expect the executable to be found. Is it temporarily in the source directory before the build finishes?

    kshegunovK 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Thanks for the replies, guys. The problem was indeed linked to a filename confusion. I renamed the project to "complex_test" and it worked just fine. You see something new every day...

      kshegunov: I was using a shadow build, so I didn't expect the executable to be found. Is it temporarily in the source directory before the build finishes?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #5

      @mzimmers said in C++ <complex> yielding strange behavior:

      Is it temporarily in the source directory before the build finishes?

      No, but if your output (build) directory is in the include path then that'd do it.

      Read and abide by the Qt Code of Conduct

      mzimmersM 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @mzimmers said in C++ <complex> yielding strange behavior:

        Is it temporarily in the source directory before the build finishes?

        No, but if your output (build) directory is in the include path then that'd do it.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #6

        @kshegunov Hmm...it's almost certainly not, at least not explicitly by anything I did. Perhaps some more experimentation is in order. I'm curious as to whether this would occur with other libraries.

        kshegunovK 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @kshegunov Hmm...it's almost certainly not, at least not explicitly by anything I did. Perhaps some more experimentation is in order. I'm curious as to whether this would occur with other libraries.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #7

          @mzimmers said in C++ <complex> yielding strange behavior:

          Hmm...it's almost certainly not, at least not explicitly by anything I did. Perhaps some more experimentation is in order. I'm curious as to whether this would occur with other libraries.

          Do you use the widgets module? If you do try to determine the .ui file's output dir, this might be a reason why the build dir may be added to the include path. Can you share the project file?

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #8

            No widgets. Here's the project file:

            TEMPLATE = app
            CONFIG += console c++11
            CONFIG -= app_bundle
            CONFIG -= qt
            
            SOURCES += \
                main.cpp
            

            Weird, huh? I'm not sure whether it's the .cpp file or the project file that's getting in the way, but we're definitely on the right track.

            1 Reply Last reply
            0
            • kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #9

              @mzimmers said in C++ <complex> yielding strange behavior:

              Weird, huh?

              Indeed. What about the compile and link line? There should be some clue somewhere why this is being included.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #10

                Here's the compile line, and a little output:

                09:40:59: Starting: "/usr/bin/make" 
                g++ -c -pipe -g -std=gnu++11 -Wall -W -fPIC -DQT_QML_DEBUG -I../complex_test -I. -I/opt/Qt/5.9/5.9.1/gcc_64/mkspecs/linux-g++ -o main.o ../complex_test/main.cpp
                In file included from ../complex_test/main.cpp:2:0:
                ./complex:1:1: error: stray ‘\177’ in program
                

                Another data point: I tried it with the source file named "main.cpp" but the project file still "complex.pro" and it failed.

                kshegunovK 1 Reply Last reply
                0
                • mzimmersM mzimmers

                  Here's the compile line, and a little output:

                  09:40:59: Starting: "/usr/bin/make" 
                  g++ -c -pipe -g -std=gnu++11 -Wall -W -fPIC -DQT_QML_DEBUG -I../complex_test -I. -I/opt/Qt/5.9/5.9.1/gcc_64/mkspecs/linux-g++ -o main.o ../complex_test/main.cpp
                  In file included from ../complex_test/main.cpp:2:0:
                  ./complex:1:1: error: stray ‘\177’ in program
                  

                  Another data point: I tried it with the source file named "main.cpp" but the project file still "complex.pro" and it failed.

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #11

                  @mzimmers said in C++ <complex> yielding strange behavior:

                  g++ ... -I. 
                  

                  This is what does it. I'm not sure where it comes from though. As a workaround rename your executable, so it doesn't conflict:

                  TARGET = complex_app
                  

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  2
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by mzimmers
                    #12

                    OK, that makes sense. I imagine this same problem would occur with other libraries as well. Good lesson learned. Thanks for the help.

                    PS: I wonder whether this would happen on Windows. I'd expect the .exe suffix to prevent it, but who knows...

                    kshegunovK 1 Reply Last reply
                    0
                    • mzimmersM mzimmers

                      OK, that makes sense. I imagine this same problem would occur with other libraries as well. Good lesson learned. Thanks for the help.

                      PS: I wonder whether this would happen on Windows. I'd expect the .exe suffix to prevent it, but who knows...

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by
                      #13

                      @mzimmers said in C++ <complex> yielding strange behavior:

                      I'd expect the .exe suffix to prevent it, but who knows...

                      Yes, that is correct, it's a linux/mac peculiarity.

                      Read and abide by the Qt Code of Conduct

                      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