Thread: Modularization

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    Modularization

    Code:
    Main.cpp - err, C
    
    #include "myhead.h"
    
    int main()
    {
        MESSAGE("Line 2 n stuff");
    }
    
    - myhead.h -
    
    #include <stdio.h>
    #include <conio.h>
    #include <io.h>
    #include <stdlib.h>
    #include <time.h>
    #include <myfuncs.h>  //clearing screen, and force full screen
    
    #define MESSAGE(x) clrscr(); printf("Line 1\n%s\nLine 3", x)
    I can replace "line" 2 from any function, or source file by calling MESSAGE("My new stuff goes here").

    Code:
    Sub source file
    
    #include "myhead.h"
    
    int blah_message()
    {
        printf("\n\nBlah");
    }
    Is there a way to make the compiler automatically link all of your source files? Do you do it with a make file? Please excuse such a newbie of a question, but I want to put in the effort before hand, so once things get going, they roll faster. Modularization.

    BTW, also excuse my huge include list - it came from another program...and I have alot of things happening right now.
    The world is waiting. I must leave you now.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yes you can use a make file to do the work for you. Alternately you (depending on your IDE/compiler combination) can set up a project (ala MSVC++) which does the work for you.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Thank you quzah.

    I just wanted to make sure there wasn't a way to embed a statement in your first source file, which tells the compiler that the main, or first source file being compiled will need something from another source file ( main.c/cpp calls something out of sub.c/cpp etc ). Your compiler will then add the infomation together during compilation without any additional work from you aside from writting a few extra lines of code.
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function pointer modularization
    By mingerso in forum C Programming
    Replies: 15
    Last Post: 03-13-2008, 07:00 PM
  2. modularization
    By Chaplin27 in forum C++ Programming
    Replies: 2
    Last Post: 08-09-2005, 09:19 AM
  3. Modularization question...
    By Chaplin27 in forum C++ Programming
    Replies: 4
    Last Post: 08-05-2005, 07:59 AM