Results 1 to 9 of 9

Thread: No need to compile?

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    No need to compile?

    I have a class in a separate .h file that I never change. Is there a way to only compile this once and not have to do it again? Or is this automatically done for me and I made a pointless post? (Visual C++ 6)
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    depands on what compiler your using
    i use vc++
    when i compile a project
    it skipps over everything i havent changed since last compile time

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you put it into a .h/.cpp combination then it will only compile it once. If it's in a header, it will compile it every time.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73

    Make

    The make program uses a makefile to compile. It only compiles what has changed. And to all of you who use Visual C++, Learn it the hard way! With GCC/G++!

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Ah, but no

    If you #include "myheader.h" into mysource.cpp, then if myheader.h changes mysource.cpp is recompiled. If you have the class in myheader.h as myclass.h/myclass.cpp and you change myclass.cpp, only that file is recompiled and not mysource.cpp
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772


    I only have two files, we'll say class.h and source.cpp. If i change source.cpp and not class.h, will class.h still be compiled?
    Alcohol & calculus don't mix.
    Never drink & derive.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Indirectly, yes. Because class.h is included directly into source.cpp by the preprocessor, compiling source.cpp requires the contents of class.h to be compiled.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Ok. Is there a way to not have to compile it?
    Alcohol & calculus don't mix.
    Never drink & derive.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yes. The code sections of the .h file should be split into a .cpp file (the implementation of a class).

    MyClass.h = contains definition of the class and its members
    MyClass.cpp = contains implementation of the class, needs compiling
    main.cpp = includes MyClass.h, if MyClass.h changes then main.cpp is recompiled. If MyClass.cpp changes then MyClass.cpp is recompiled but not main.cpp. If main.cpp is changed MyClass.cpp is not recompiled.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width