making changes to a header

This is a discussion on making changes to a header within the C++ Programming forums, part of the General Programming Boards category; how come when i recompile my source after making changes in a header file... the program doesn't update... example... if ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    76

    making changes to a header

    how come when i recompile my source after making changes in a header file... the program doesn't update...

    example... if i had string in the header that i wanted to edit... the edited string wouldnt show up in the program after i recompiled it...

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Post some code man!

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    ill post some example code... im just talking in general

    example.h
    Code:
    #include <iostream>
    using namespace std;
    
    // Prototypes
    void Say();
    
    //Definitions
    void Say()
    {
         cout<<"Hello thel;asdlf";  // Not what i want
    }
    example.cpp
    Code:
    #include "example.h"
    
    int main()
    {
         Say();
         return 0;
    }
    This output after compiling would be...

    >Hello thel;asdlf

    So if i wanted to change this... id make the following correction

    example.h
    Code:
    ...
    void Say()
    {
         cout<<"Hello there!";  // This would be what i wanted
    }
    ...
    However, if i recompiled the project... it would still output

    >Hello thel;asdlf

  4. #4
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    On Dev-C++, it will only recompile the source if the source in the cpp file is edited, so just change something in the main cpp file and change it back, like removing a space or something and press F9 again, it is anoying though but this is how I do it.

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    It may be something to do with building something beforehand. What compiler, OS are you using, (not that I know what difference it makes, but someone should ... and it'll save them asking :P )?
    Last edited by twomers; 05-14-2006 at 03:48 PM.

  6. #6
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    On Dev-C++, you can "rebuild all." Then you don't have to do the space/delete thing. I'm not at home, so I can't tell you what the keypress command is, but it should be 3 buttons to the right of the compile button on the toolbar, if that helps. Other IDEs may (should?) have a similar command.
    There is a difference between tedious and difficult.

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    I see the Rebuild All... i always wondered what that was for...
    thank you

  8. #8
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    There's also the Clean option - basically from my experience, IDE's
    can be a little stupid when compiling multiple file projects, such
    that only the source file containing main is recompiled (although
    there may be other variants). Clean deletes any existing build
    information and allows compile from scratch, whereas Rebuild All
    may either combine the Clean and Build commands, or more
    intelligently, rebuild all items older than the most recent file
    timestamp. This is compiler specific I'd say, not that it would
    matter too much for typical single programmer projects.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  2. IP header "total length" vs. packet size
    By MK27 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-04-2009, 07:45 AM
  3. class header confusion
    By te5la in forum C++ Programming
    Replies: 2
    Last Post: 07-22-2008, 03:39 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. Replies: 6
    Last Post: 04-02-2002, 05:46 AM

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