C/C++

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Does the following program architecture make sense?

    3 answers - 327 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    #include <stdio.h>
    #include "test1.c"
    #include "sample.cpp"
    int main(void){
    output();
    output();
    testmain();
    getchar();
    return 0;
    }
    #include"test1.c"
    #include"sample.cpp"
    include *.c and *.cpp at the same time?
    Thank You
    Best Regards
  • No.1 | | 573 bytes | |


    mikelinyoho wrote:
    #include <stdio.h>
    #include "test1.c"
    #include "sample.cpp"

    int main(void){
    output();
    output();

    testmain();
    --
    getchar();
    return 0;

    }

    #include"test1.c"
    #include"sample.cpp"

    include *.c and *.cpp at the same time?

    it is very unusual to include a ".c" file. It is close to being a
    "never do this".
    If you want to call things in another ".c" file then link them together
    (see
    your compiler documentation).

    Does your program really contain both C and C++ code?
  • No.2 | | 815 bytes | |

    mikelinyoho wrote:
    #include <stdio.h>
    #include "test1.c"
    #include "sample.cpp"

    int main(void){
    output();
    output();

    testmain();
    --
    getchar();
    return 0;

    }

    #include"test1.c"
    #include"sample.cpp"

    include *.c and *.cpp at the same time?

    If you compile as a C++ program (using a C++ compiler) it may compile.
    A C only compiler (or one compiling as C) will reject the contents of
    the
    "sample.cpp" file, if they contain C++ code.

    Although 'include' files can have any suffix, their contents must be
    syntactically and semantically correct for the particular program in
    which they are included, under a particular compiler operating under
    particular switches. The programmer has to figure it out.

  • No.3 | | 779 bytes | |


    "mikelinyoho" <mikelinyoho@gmail.comwrote
    #include <stdio.h>
    #include "test1.c"
    #include "sample.cpp"

    int main(void){
    output();
    output();

    testmain();
    --
    getchar();
    return 0;

    }

    #include"test1.c"
    #include"sample.cpp"

    include *.c and *.cpp at the same time?

    Yes.
    It is pretty horrible but programs can easily be written in C to compile as
    C++, and sometimes you might want to paste together a source file from
    multiple includes.
    (Normally you would just compile the source files separately and link, but
    if you are doing something messy and ugly with globals / statics there might
    be a reason for not doing so. As I said, it pretty horrible but not
    senseless).

Re: Does the following program architecture make sense?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "C/C++"

EMSDN.COM