Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ cout in header file error - ‘cout’ was not declared in this scope

C++ cout in header file error - ‘cout’ was not declared in this scope

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingquestion
20 Posts 5 Posters 0 Views 1 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.
  • L Lost User

    Impossible to be sure what you are doing. Please show your code and explain what errors occur.

    V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #6

    OK, here is readers digest for clarification. The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp. This file first code line is #define MY_DEBUG and the cout code works in main OK BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG. Without the #include using namespace std; added to TESTCLASS1.h When I add ONLY #define MY_DEBUG I get the cout error. Basically I have two issues 1. why do I need to redefine MY_DEBUG in TESTCLASS1.h 2. why do I need to add #include using namespace std; to get cout to work in added class and a minor request for help with should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?

    //============================================================================
    // Name : HF_VNA_CROSS_CPP.cpp
    // Author :
    // Version :
    // Copyright : Your copyright notice
    // Description : Hello World in C++, Ansi-style
    //============================================================================

    #define MY_DEBUG

    #include
    using namespace std;

    #include // rint round up math
    #include
    #include

    #include
    #include
    #include
    #include
    #include
    #include // rint round up math
    #include "/usr/local/include/wiringPiSPI.h"

    #include // rint round up math libraray lm

    #include "flash_DTR.h" // flash DTR via USB port
    /* CCC temp out
    #include "AD9851.h" // AD9851 via SPI / I2C
    #include "LCD_SPI.h" // LCD via SPI
    */

    #include "MY_wiringPi.h" // GPIO for RPi

    //#include "LCD.h" // TEST CLASS
    //#include "TESTCLASS.h" //
    //#include "LCDSPI.h" // NO SPACE

    #include "TESTCLASS1.h"

    int main() {
    cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

    //temp bypass CCC
    	// class test block start
    	{
    

    #ifdef MY_DEBUG
    cout << " process code block START"<< endl;
    cout << "*** TRACE file " << __FILE__<< endl;
    cout <<" function " <<__FUNCTION__<

    L J D 4 Replies Last reply
    0
    • V Vaclav_

      OK, here is readers digest for clarification. The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp. This file first code line is #define MY_DEBUG and the cout code works in main OK BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG. Without the #include using namespace std; added to TESTCLASS1.h When I add ONLY #define MY_DEBUG I get the cout error. Basically I have two issues 1. why do I need to redefine MY_DEBUG in TESTCLASS1.h 2. why do I need to add #include using namespace std; to get cout to work in added class and a minor request for help with should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?

      //============================================================================
      // Name : HF_VNA_CROSS_CPP.cpp
      // Author :
      // Version :
      // Copyright : Your copyright notice
      // Description : Hello World in C++, Ansi-style
      //============================================================================

      #define MY_DEBUG

      #include
      using namespace std;

      #include // rint round up math
      #include
      #include

      #include
      #include
      #include
      #include
      #include
      #include // rint round up math
      #include "/usr/local/include/wiringPiSPI.h"

      #include // rint round up math libraray lm

      #include "flash_DTR.h" // flash DTR via USB port
      /* CCC temp out
      #include "AD9851.h" // AD9851 via SPI / I2C
      #include "LCD_SPI.h" // LCD via SPI
      */

      #include "MY_wiringPi.h" // GPIO for RPi

      //#include "LCD.h" // TEST CLASS
      //#include "TESTCLASS.h" //
      //#include "LCDSPI.h" // NO SPACE

      #include "TESTCLASS1.h"

      int main() {
      cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

      //temp bypass CCC
      	// class test block start
      	{
      

      #ifdef MY_DEBUG
      cout << " process code block START"<< endl;
      cout << "*** TRACE file " << __FILE__<< endl;
      cout <<" function " <<__FUNCTION__<

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #7

      Why do you #define MY_DEBUG in that header file since it serves no purpose? You should write code that depends on #define statements,but only use the #define at the beginning of your source code. Something like (note the correct use of <pre> tags):

      // some .h file
      #if defined(SOME_TAG)
      // statements to be included if SOME_TAG is defined
      #endif

      // main .cpp file
      #define SOME_TAG // or not as the case may be
      #include some .h file

      // other code including blocks like ...
      #if defined(SOME_TAG)
      // statements to be included if SOME_TAG is defined
      #endif

      V 1 Reply Last reply
      0
      • V Vaclav_

        OK, here is readers digest for clarification. The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp. This file first code line is #define MY_DEBUG and the cout code works in main OK BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG. Without the #include using namespace std; added to TESTCLASS1.h When I add ONLY #define MY_DEBUG I get the cout error. Basically I have two issues 1. why do I need to redefine MY_DEBUG in TESTCLASS1.h 2. why do I need to add #include using namespace std; to get cout to work in added class and a minor request for help with should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?

        //============================================================================
        // Name : HF_VNA_CROSS_CPP.cpp
        // Author :
        // Version :
        // Copyright : Your copyright notice
        // Description : Hello World in C++, Ansi-style
        //============================================================================

        #define MY_DEBUG

        #include
        using namespace std;

        #include // rint round up math
        #include
        #include

        #include
        #include
        #include
        #include
        #include
        #include // rint round up math
        #include "/usr/local/include/wiringPiSPI.h"

        #include // rint round up math libraray lm

        #include "flash_DTR.h" // flash DTR via USB port
        /* CCC temp out
        #include "AD9851.h" // AD9851 via SPI / I2C
        #include "LCD_SPI.h" // LCD via SPI
        */

        #include "MY_wiringPi.h" // GPIO for RPi

        //#include "LCD.h" // TEST CLASS
        //#include "TESTCLASS.h" //
        //#include "LCDSPI.h" // NO SPACE

        #include "TESTCLASS1.h"

        int main() {
        cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

        //temp bypass CCC
        	// class test block start
        	{
        

        #ifdef MY_DEBUG
        cout << " process code block START"<< endl;
        cout << "*** TRACE file " << __FILE__<< endl;
        cout <<" function " <<__FUNCTION__<

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #8

        The error seems to be here:

        namespace std {

        class TEST_CLASS_1 {
        public:
        TEST_CLASS_1();
        virtual ~TEST_CLASS_1();

        int TestFunction(void);
        };

        You are trying to extend the std namespace. But that is not allowed:

        Extending the namespace std - cppreference.com[^]:

        It is undefined behavior to add declarations or definitions to namespace std or to any namespace nested within std, with a few exceptions noted below

        V 1 Reply Last reply
        0
        • L Lost User

          Why do you #define MY_DEBUG in that header file since it serves no purpose? You should write code that depends on #define statements,but only use the #define at the beginning of your source code. Something like (note the correct use of <pre> tags):

          // some .h file
          #if defined(SOME_TAG)
          // statements to be included if SOME_TAG is defined
          #endif

          // main .cpp file
          #define SOME_TAG // or not as the case may be
          #include some .h file

          // other code including blocks like ...
          #if defined(SOME_TAG)
          // statements to be included if SOME_TAG is defined
          #endif

          V Offline
          V Offline
          Vaclav_
          wrote on last edited by
          #9

          Richard please no more replies. If you do not understand the problem - stay out of it and you will Save yourself some time. I posted two descriptions and you obviously did not get it and went back to your preaching instead. It has been nice not to hear from you for a while , so let's keep it that way.PLEASE.

          L 1 Reply Last reply
          0
          • J Jochen Arndt

            The error seems to be here:

            namespace std {

            class TEST_CLASS_1 {
            public:
            TEST_CLASS_1();
            virtual ~TEST_CLASS_1();

            int TestFunction(void);
            };

            You are trying to extend the std namespace. But that is not allowed:

            Extending the namespace std - cppreference.com[^]:

            It is undefined behavior to add declarations or definitions to namespace std or to any namespace nested within std, with a few exceptions noted below

            V Offline
            V Offline
            Vaclav_
            wrote on last edited by
            #10

            That is the way Eclipse builds the class when asked for "namespace". But it fails same way when I do namespace std; I really think I have to figure out first why I cannot do #define MY_DEBUG once in the main .cpp Let me work on that.

            J 1 Reply Last reply
            0
            • V Vaclav_

              OK, here is readers digest for clarification. The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp. This file first code line is #define MY_DEBUG and the cout code works in main OK BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG. Without the #include using namespace std; added to TESTCLASS1.h When I add ONLY #define MY_DEBUG I get the cout error. Basically I have two issues 1. why do I need to redefine MY_DEBUG in TESTCLASS1.h 2. why do I need to add #include using namespace std; to get cout to work in added class and a minor request for help with should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?

              //============================================================================
              // Name : HF_VNA_CROSS_CPP.cpp
              // Author :
              // Version :
              // Copyright : Your copyright notice
              // Description : Hello World in C++, Ansi-style
              //============================================================================

              #define MY_DEBUG

              #include
              using namespace std;

              #include // rint round up math
              #include
              #include

              #include
              #include
              #include
              #include
              #include
              #include // rint round up math
              #include "/usr/local/include/wiringPiSPI.h"

              #include // rint round up math libraray lm

              #include "flash_DTR.h" // flash DTR via USB port
              /* CCC temp out
              #include "AD9851.h" // AD9851 via SPI / I2C
              #include "LCD_SPI.h" // LCD via SPI
              */

              #include "MY_wiringPi.h" // GPIO for RPi

              //#include "LCD.h" // TEST CLASS
              //#include "TESTCLASS.h" //
              //#include "LCDSPI.h" // NO SPACE

              #include "TESTCLASS1.h"

              int main() {
              cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

              //temp bypass CCC
              	// class test block start
              	{
              

              #ifdef MY_DEBUG
              cout << " process code block START"<< endl;
              cout << "*** TRACE file " << __FILE__<< endl;
              cout <<" function " <<__FUNCTION__<

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #11

              Vaclav_Sal wrote:

              // class test block end // */ return 43;

              Where's the matching comment?

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              1 Reply Last reply
              0
              • V Vaclav_

                OK, here is readers digest for clarification. The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp. This file first code line is #define MY_DEBUG and the cout code works in main OK BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG. Without the #include using namespace std; added to TESTCLASS1.h When I add ONLY #define MY_DEBUG I get the cout error. Basically I have two issues 1. why do I need to redefine MY_DEBUG in TESTCLASS1.h 2. why do I need to add #include using namespace std; to get cout to work in added class and a minor request for help with should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?

                //============================================================================
                // Name : HF_VNA_CROSS_CPP.cpp
                // Author :
                // Version :
                // Copyright : Your copyright notice
                // Description : Hello World in C++, Ansi-style
                //============================================================================

                #define MY_DEBUG

                #include
                using namespace std;

                #include // rint round up math
                #include
                #include

                #include
                #include
                #include
                #include
                #include
                #include // rint round up math
                #include "/usr/local/include/wiringPiSPI.h"

                #include // rint round up math libraray lm

                #include "flash_DTR.h" // flash DTR via USB port
                /* CCC temp out
                #include "AD9851.h" // AD9851 via SPI / I2C
                #include "LCD_SPI.h" // LCD via SPI
                */

                #include "MY_wiringPi.h" // GPIO for RPi

                //#include "LCD.h" // TEST CLASS
                //#include "TESTCLASS.h" //
                //#include "LCDSPI.h" // NO SPACE

                #include "TESTCLASS1.h"

                int main() {
                cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

                //temp bypass CCC
                	// class test block start
                	{
                

                #ifdef MY_DEBUG
                cout << " process code block START"<< endl;
                cout << "*** TRACE file " << __FILE__<< endl;
                cout <<" function " <<__FUNCTION__<

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #12

                I took your code and plugged it into Visual Studio with the following changes: ***** stdafx.h ***** (I turned off pre-compiled headers so that it would more closely mimic GCC)

                #define MY_DEBUG

                #include #include // rint round up math
                #include #include #include //#include #include //#include //#include #include // rint round up math
                //#include "/usr/local/include/wiringPiSPI.h"

                #include // rint round up math libraray lm

                using namespace std;

                ***** hf_vna_cross_cpp.cpp *****

                #include "stdafx.h"

                //#include "flash_DTR.h" // flash DTR via USB port
                /* CCC temp out
                #include "AD9851.h" // AD9851 via SPI / I2C
                #include "LCD_SPI.h" // LCD via SPI
                */

                //#include "MY_wiringPi.h" // GPIO for RPi

                //#include "LCD.h" // TEST CLASS
                //#include "TESTCLASS.h" //
                //#include "LCDSPI.h" // NO SPACE

                #include "TESTCLASS1.h"

                int main() {
                cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

                //temp bypass CCC
                // class test block start
                {
                #ifdef MY_DEBUG
                cout << " process code block START"<< endl;
                cout << "*** TRACE file " << __FILE__<< endl;
                cout <<" function " <<__FUNCTION__<

                ***** testclass1.h *****

                #ifndef TESTCLASS1_H_
                #define TESTCLASS1_H_

                #include "stdafx.h"

                class TEST_CLASS_1
                {
                public:
                TEST_CLASS_1(){}
                virtual ~TEST_CLASS_1(){}

                    int TestFunction(void){return 1
                
                V 1 Reply Last reply
                0
                • V Vaclav_

                  Richard please no more replies. If you do not understand the problem - stay out of it and you will Save yourself some time. I posted two descriptions and you obviously did not get it and went back to your preaching instead. It has been nice not to hear from you for a while , so let's keep it that way.PLEASE.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #13

                  Funny, I feel exactly the same.

                  1 Reply Last reply
                  0
                  • V Vaclav_

                    That is the way Eclipse builds the class when asked for "namespace". But it fails same way when I do namespace std; I really think I have to figure out first why I cannot do #define MY_DEBUG once in the main .cpp Let me work on that.

                    J Offline
                    J Offline
                    Jochen Arndt
                    wrote on last edited by
                    #14

                    Vaclav_Sal wrote:

                    That is the way Eclipse builds the class when asked for "namespace".

                    It means that you can enter the name of your own namespace but not to enter the name of the reserved std namespace. I don't know Eclipse good enough. But it should be possible to create a class without a namespace (which is creating it in the global namespace). Regarding the define: It should be only defined once; usually in a header file. If you want to define it multiple times, it should be guarded:

                    #ifndef MY_DEBUG
                    #define MY_DEBUG
                    #endif

                    1 Reply Last reply
                    0
                    • D David Crow

                      I took your code and plugged it into Visual Studio with the following changes: ***** stdafx.h ***** (I turned off pre-compiled headers so that it would more closely mimic GCC)

                      #define MY_DEBUG

                      #include #include // rint round up math
                      #include #include #include //#include #include //#include //#include #include // rint round up math
                      //#include "/usr/local/include/wiringPiSPI.h"

                      #include // rint round up math libraray lm

                      using namespace std;

                      ***** hf_vna_cross_cpp.cpp *****

                      #include "stdafx.h"

                      //#include "flash_DTR.h" // flash DTR via USB port
                      /* CCC temp out
                      #include "AD9851.h" // AD9851 via SPI / I2C
                      #include "LCD_SPI.h" // LCD via SPI
                      */

                      //#include "MY_wiringPi.h" // GPIO for RPi

                      //#include "LCD.h" // TEST CLASS
                      //#include "TESTCLASS.h" //
                      //#include "LCDSPI.h" // NO SPACE

                      #include "TESTCLASS1.h"

                      int main() {
                      cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

                      //temp bypass CCC
                      // class test block start
                      {
                      #ifdef MY_DEBUG
                      cout << " process code block START"<< endl;
                      cout << "*** TRACE file " << __FILE__<< endl;
                      cout <<" function " <<__FUNCTION__<

                      ***** testclass1.h *****

                      #ifndef TESTCLASS1_H_
                      #define TESTCLASS1_H_

                      #include "stdafx.h"

                      class TEST_CLASS_1
                      {
                      public:
                      TEST_CLASS_1(){}
                      virtual ~TEST_CLASS_1(){}

                          int TestFunction(void){return 1
                      
                      V Offline
                      V Offline
                      Vaclav_
                      wrote on last edited by
                      #15

                      I am sorry you went thru all this , but the issue is not in compiling. The code just need those "redefinitions" to work, it compiles fine. I ll go thru your code to see if there is some other change I could use. . My Ellipse is on strike again - the code is not passing updated executable to the remote system. I have to fix that to see if any modifications make it work. The "gcc" has an option to -include file and if I put the #define DEBUG in header file and use this compiler -include option it should work.

                      D L 2 Replies Last reply
                      0
                      • V Vaclav_

                        I have a "scaffolding printout" in main C++ function working just fine in { #ifdef MY_DEBUG ... #endif } debug code block . I have included a test header file with a class and I have a test function there with same debug code block . I have to redefine #define MY_DEBUG and re-include #include using namespace std; in the added header file to get the debug test printout. I have never experienced such (odd) behavior, or is that normal? This is my first real crosscompiled CPP app if that matters. Not looking forward including all this in every header file. Perhaps it is a compiler / crosscompiler (gcc) options I have missed? Thanks for any hints / help Cheers Vaclav

                        V Offline
                        V Offline
                        Vaclav_
                        wrote on last edited by
                        #16

                        OK, I got it doing what I want putting all the requirements into a common header file and just including it in each class. Here is my final question - does't compiler do each object file independently and linker puts them together? That would explain why I need to redefine all. DEBUG and other. Cheers

                        J 1 Reply Last reply
                        0
                        • V Vaclav_

                          I am sorry you went thru all this , but the issue is not in compiling. The code just need those "redefinitions" to work, it compiles fine. I ll go thru your code to see if there is some other change I could use. . My Ellipse is on strike again - the code is not passing updated executable to the remote system. I have to fix that to see if any modifications make it work. The "gcc" has an option to -include file and if I put the #define DEBUG in header file and use this compiler -include option it should work.

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #17

                          Vaclav_Sal wrote:

                          I am sorry you went thru all this , but the issue is not in compiling. The code just need those "redefinitions" to work, it compiles fine.

                          I only mentioned that it compiled fine to show that your code still compiles even with MY_DEBUG and namespace std being defined in one place only.

                          "One man's wage rise is another man's price increase." - Harold Wilson

                          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                          1 Reply Last reply
                          0
                          • V Vaclav_

                            OK, I got it doing what I want putting all the requirements into a common header file and just including it in each class. Here is my final question - does't compiler do each object file independently and linker puts them together? That would explain why I need to redefine all. DEBUG and other. Cheers

                            J Offline
                            J Offline
                            Jochen Arndt
                            wrote on last edited by
                            #18

                            A compiler processes source files and creates an object file for each of the source files. These object files are then passed to the linker together with libraries to create an executable or a library. The compiling process itself is not a single run but consists of multiple passes with three main tasks for the GCC:

                            1. Running the preprocessor
                            2. Compiling the intermediate file created by the preprocessing to assembly code
                            3. Creating object files from the assembly code files

                            In your case it is all related to the preprocessor. That will look for the preprocessing directives (those beginning with #), process them and create an intermediate file. This intermediate file is then used for compilation. It will not contain #defines anymore. If you want to see how it works, you can let GCC do each step separately and create corresponding output files which can then be inspected (use g++ for *.cpp files with *.ii as intermediate file extension):

                            # Run the preprocessor and stop

                            The result is printed to stdout and redirected to a file

                            gcc -E example.c > example.i

                            Compile passing the intermediate file and stop

                            Creates assembly code file example.s

                            gcc -S example.i

                            Compile passing the assembly code file and stop (do not link)

                            Creates object file example.o

                            gcc -c example.s

                            You might also use

                            gcc -save-temps -c example.c

                            to prevent deletion of the *.i and *.s intermediate files so that they can be inspected.

                            V 1 Reply Last reply
                            0
                            • V Vaclav_

                              I am sorry you went thru all this , but the issue is not in compiling. The code just need those "redefinitions" to work, it compiles fine. I ll go thru your code to see if there is some other change I could use. . My Ellipse is on strike again - the code is not passing updated executable to the remote system. I have to fix that to see if any modifications make it work. The "gcc" has an option to -include file and if I put the #define DEBUG in header file and use this compiler -include option it should work.

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #19

                              And if you took my advice and wrote the code the way it is supposed to be written it would probably be working by now. But you would rather come back with your usual whiny comments.

                              1 Reply Last reply
                              0
                              • J Jochen Arndt

                                A compiler processes source files and creates an object file for each of the source files. These object files are then passed to the linker together with libraries to create an executable or a library. The compiling process itself is not a single run but consists of multiple passes with three main tasks for the GCC:

                                1. Running the preprocessor
                                2. Compiling the intermediate file created by the preprocessing to assembly code
                                3. Creating object files from the assembly code files

                                In your case it is all related to the preprocessor. That will look for the preprocessing directives (those beginning with #), process them and create an intermediate file. This intermediate file is then used for compilation. It will not contain #defines anymore. If you want to see how it works, you can let GCC do each step separately and create corresponding output files which can then be inspected (use g++ for *.cpp files with *.ii as intermediate file extension):

                                # Run the preprocessor and stop

                                The result is printed to stdout and redirected to a file

                                gcc -E example.c > example.i

                                Compile passing the intermediate file and stop

                                Creates assembly code file example.s

                                gcc -S example.i

                                Compile passing the assembly code file and stop (do not link)

                                Creates object file example.o

                                gcc -c example.s

                                You might also use

                                gcc -save-temps -c example.c

                                to prevent deletion of the *.i and *.s intermediate files so that they can be inspected.

                                V Offline
                                V Offline
                                Vaclav_
                                wrote on last edited by
                                #20

                                Thanks, I believe you are saying, in a different way , what I concluded. Each source (.cpp) is being compiled interdependently therefore HAS to have all of the "parameters" In my case #define DEBUG use namespace std; and #include (there is another discussion about using namesapce std and cout). I did added -v for verbose output from both compiler and linker and with little patience ( few lines of output ) I can see both processes. Appreciate all who participated in discussion of actually very fundamental process as comping and linking. Thanks everybody. Cheers Vaclav

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups