Menu

Error : in file included from....

2010-11-29
2012-09-26
  • panos eglezos

    panos eglezos - 2010-11-29

    hello.
    I've recently started learning C++ . i believe i've nailed the very basics :P
    and i just tried to create a simple project, just to understand how projects
    work.
    here is the problem i've created the main source file (say main1.c) a function
    (say boo.c) and the prototype (boo.h)
    so my main is like

    include <stdio.h>

    include "boo.h"

    int main (void)
    {...
    k=boo(m)
    ...
    }

    and i cant compile it.
    here is what the compiler says:
    2 C:\Dev-Cpp\include\stdio.h:26, from M3n-1.c In file included from C:/Dev-
    Cpp/include/stdio.h:26, from M3n-1.c
    2 C:\Users\panos\Documents\C projects\M3n-1.c from M3n-1.c
    6:2 C:\Dev-Cpp\include\stddef.h #include_next is a GCC extension
    2 C:\Dev-Cpp\include\stdio.h:28, from M3n-1.c In file included from C:/Dev-
    Cpp/include/stdio.h:28, from M3n-1.c
    2 C:\Dev-Cpp\include\stdio.h:28, from M3n-1.c In file included from C:/Dev-
    Cpp/include/stdio.h:28, from M3n-1.c
    2 C:\Users\panos\Documents\C projects\M3n-1.c from M3n-1.c
    6:2 C:\Dev-Cpp\include\stdarg.h #include_next is a GCC extension
    C:\Users\panos\Documents\C projects\Makefile.win Error 1

     
  • panos eglezos

    panos eglezos - 2010-11-29

    oh sorry! i forgot to mention
    I use dev C++ 4.9.9.2 and windows 7 :)

     
  • DARC

    DARC - 2010-11-30

    i haven't programmed in awhile. but isnt part of the basics adding a semi-
    colon after each statement?

     
  • Steve A

    Steve A - 2010-11-30

    What "davidarod" is saying is that :
    k=boo(m)
    should look like:
    k=boo(m);

    also,
    the error message is quite specific as to this message:
    2 C:\Users\panos\Documents\C projects\M3n-1.c from M3n-1.c

    It looks like, in addition to main1.c, boo.c and boo.h, there is another
    reference to "M3n-1.c".
    The error even gives the exact path to "M3n-1.c".

    What is the code in boo.h ?
    What is boo.c ?
    Is it a file or just a function ?
    With the extension ".c" it should be a file.

    Files Main1.c and boo.h sound valid.
    But, if "boo" is a function, is it also a file ?

     
  • Steve A

    Steve A - 2010-11-30

    Assuming boo.c is a file and a function, your basic program should look
    something like this:

    <file:---------- main.c="" --------="">

    include <stdio.h>

    include "boo.h"

    include "boo.c"

    int main()
    {
    int m = 1, k;

    k = boo(m);
    printf("result = %d\n", k);
    system("pause");

    return 0;
    }
    <end --------="" file="">

    <file:-------- boo.h="" ---------="">
    //prototypes

    int boo(int);

    <end ----------="" file="">

    <file: --------="" boo.c="" --------="">
    int boo(int x)
    {
    printf("hello\n");
    x++;
    return x;
    }
    <end ---------="" file="">

    If you do it this way, Do Not "ADD" boo.h nor boo.c into the
    project.

    Main.c should be the only project file.
    Any other files will be included using the preprocessor #include
    statement.

     
  • panos eglezos

    panos eglezos - 2010-11-30

    ah i guess i should be more specific. actually my main is m3n-1.c main1.c is
    just a random name, but since i copied the compiler log, m3n-1 came up. sorry
    for the confusion. so this is the main:

    include <stdio.h>

    include "isodd.h"

    int main (void)
    { int m,c,n;
    m=56;
    while (n!=1) {
    c= isodd(m);
    if (c==1)
    m=3*m+1;
    else
    m=m/2;
    }
    printf("%d",m);
    return 0;
    }

    (i already had typed the ' ; ' i forgot it at the previous post)

    this is isodd :int isodd(int n)
    { if (n%2==1)
    return 1;
    else
    return 0;
    }

    i just saved it with the ".c" extension.
    and the isodd.h

    int isodd(int);

    just saved it whith the '.h ' extension.

    i've got really confused because in the compile log stdio.h is refered . i
    mean, what could be wrong there?
    i hope that it's not a really stupid mistake like a missing ' ; ' :P... thanx
    for your time.

     
  • panos eglezos

    panos eglezos - 2010-11-30

    oh and i just added #include isodd.c before main , like your example ...
    nothing changed :/

     
  • panos eglezos

    panos eglezos - 2010-11-30

    aah i just noticed that this compile log shows up (whithout the last line) in
    every program that i've included stdio.h but i can run it without problems!
    that didn't happen before i tried to compile the project ! i reinstalled dev
    C++ and it's the same ! i just don't get this :s

     
  • Steve A

    Steve A - 2010-11-30

    Okay, I've rewritten your code here, so that it should work if the logic is
    correct (which it isn't).

    include <stdio.h>

    include "isodd.h"

    int main()
    { int m, c, n;

    m = 56;

    while (n != 1) // n is not initialized
    { // ie n has no meaningful value
    // what is n's value supposed to be ?

    c = isodd(m);

    if(c == 1)
    {
    m = 3 * m + 1;
    }
    else
    {
    m = m / 2;
    }
    } // this is an infinite loop
    // because "n" never changes

    printf("%d\n", m);
    system("pause");

    return 0;
    }

    int isodd(int n)
    {
    if(n % 2 == 1)
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }

    The first thing you need to establish is what "n"s initial value is at the
    start of the program.
    As it stands, it sets up an infinite loop and does nothing.

    Steve

     
  • panos eglezos

    panos eglezos - 2010-12-01

    you are right about n! trying to solve the problem myself i was changing in
    some ways the code to see if it would work, it didn't :P so i changed back but
    i guess i forgot "n" . actually it is supposed to be "while (m!=1)" and n
    wouldn't exist at all. i corrected the code , i got rid of the "n", and the
    compile log is exactly the same and the program doesn't run ! As i sead
    before, ever since i tried to run the project i get the firsts lines of the
    compile code in every program that i include stdio.h ! for example here is the
    compile log of the "hello world" program :
    2 C:\Dev-Cpp\include\stdio.h:26, from C:\Users\panos\Documents\diafora
    C++\helloworld.c In file included from C:/Dev-Cpp/include/stdio.h:26, from
    C:\Users\panos\Documents\diafora C++\helloworld.c
    2 C:\Users\panos\Documents\diafora C++\helloworld.c from
    C:\Users\panos\Documents\diafora C++\helloworld.c
    6:2 C:\Dev-Cpp\include\stddef.h #include_next is a GCC extension
    2 C:\Dev-Cpp\include\stdio.h:28, from C:\Users\panos\Documents\diafora
    C++\helloworld.c In file included from C:/Dev-Cpp/include/stdio.h:28, from
    C:\Users\panos\Documents\diafora C++\helloworld.c
    2 C:\Users\panos\Documents\diafora C++\helloworld.c from
    C:\Users\panos\Documents\diafora C++\helloworld.c
    6:2 C:\Dev-Cpp\include\stdarg.h #include_next is a GCC extension

    that didn't happen defore i tried to run the project, hello world stll runs
    just fine, but what is this?
    (i also reinstalled dev C++ and nothing changed :S )

     
  • Steve A

    Steve A - 2010-12-01

    Okay, one potential problem I see is that your path has blankspaces in it:

    2 C:\Users\panos\Documents\diafora C++\helloworld.c

    between "\diafora" and "C++\".

    That is a known problem.
    Neither DevC++ nor your project should have "blank space" in the name.
    A number of compilers I work with have the same issue.
    Always install Dev-C++ in a subdirectory off of the root:
    like: C:\DevC++...
    or: C:\Programming\DevC++...

    and your projects in a similar folder, and not your documents folder:
    like: C:\Programming\DevProjects...

    not: C:\Users\panos\Documents\diafora C++\helloworld.c

    Also, it's advisable (in most cases) that the Dev install directory not be
    used as the projects diretory.

     
  • Steve A

    Steve A - 2010-12-01

    Here is a new version of the the program that compiles and runs correctly:

    include <stdio.h>

    include "isodd.h"

    int main()
    { int m, c;

    m = 56;

    while(m != 1)
    {
    c = isodd(m);
    printf("c=%d m=%d\n", c, m);
    system("pause");

    if(c == 1)
    {
    m = 3 * m + 1;
    }
    else
    {
    m = m / 2;
    }
    }

    printf("m=%d\n", m);
    system("pause");

    return 0;
    }

    int isodd(int n)
    {
    if(n % 2 == 1)
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }

    I have added some pauses so that you can see what is happening to the data as
    well.

    Here is the compile log:

    Compiler: Default compiler
    Building Makefile: "C:\Programming\Dev-Cpp\Winprog\Test1\Makefile.win"
    Executing make clean
    rm -f main.o test1.exe
    gcc.exe -c main.c -o main.o
    gcc.exe main.o -o "test1.exe"
    Execution terminated
    Compilation successful

    Note, that I built this in a sub-folder, within the Dev install folder:

    Building Makefile: "C:\Programming\Dev-Cpp\Winprog\Test1\Makefile.win"

    Sometimes Dev will allow it, sometimes not. It depends on other environment
    variables.
    I would normally recommend against it because it is a known issue.

    Steve

     
  • panos eglezos

    panos eglezos - 2010-12-01

    I'm sorry, i did whatever you suggested but nothing changed :/ ... could it be
    something else?
    Thanx alot for your time, i really apreciate it.

     
  • Steve A

    Steve A - 2010-12-01

    Post your Compile Log.

     
  • Steve A

    Steve A - 2010-12-01

    Additionally, Dev-C++, (in it's present form), may simply be too old for use
    on windows 7.
    Check out this link:

    http://wxdsgn.sourceforge.net/

    Steve

     
  • panos eglezos

    panos eglezos - 2010-12-02

    aha maybe that's the problem.

    this is my compile log (i actually erased the whole project and i copied your
    code, i changed the name of main, it's mymain now isodd is still isodd) :

    Compiler: Default compiler
    Building Makefile: "C:\Users\panos\Documents\Cprojects\Makefile.win"
    Finding dependencies for file: C:\Users\panos\Documents\Cprojects\mymain.c
    Finding dependencies for file: C:\Users\panos\Documents\Cprojects\isodd.c
    Executing make...
    make.exe -f "C:\Users\panos\Documents\Cprojects\Makefile.win" all
    gcc.exe -c mymain.c -o mymain.o -I"C:/Dev-Cpp/include" -ansi -pedantic-errors
    -Wall -W -Wshadow -Wunreachable-code -Wno-long-long -Wno-return-type -Wno-
    implicit-int -Wno-unused-function -Wno-unused-parameter -g3

    In file included from C:/Dev-Cpp/include/stdio.h:26,
    from mymain.c:1:
    C:/Dev-Cpp/include/stddef.h:6:2: #include_next is a GCC extension
    In file included from C:/Dev-Cpp/include/stdio.h:28,
    from mymain.c:1:
    C:/Dev-Cpp/include/stdarg.h:6:2: #include_next is a GCC extension

    make.exe: *** Error 1

    Execution terminated

    i'll certainly check out wxDev C++. if you can't came up with something else
    it's ok, perhaps it's because of the windows 7. i have an older pc with
    windows xp i'll try to run the program there .

    Thx, Panos

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.