Tobbe Posted July 15, 2003 Share Posted July 15, 2003 I downloaded Borlands C++ Compiler 5.5 and when I'm about to compile a file with cpp32.exe then I get error. My code: Quote #include <stdio.h>#include <iostream.h> int main(void) { cout <<< "Hol?"; return 0; } The error: Quote Warning W8017 c:\Program\Borland\BCC55\Include\stdlib.h 117: Redefinition of 'abs' is not identical Why aren't the definitions identical? Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/ Share on other sites More sharing options...
0 Oogle Posted July 15, 2003 Share Posted July 15, 2003 Try this... #include <iostream> // DON'T PUT THE .H AT THE END!!! using namespace std; int main(void) { cout << "Hol?"; return 0; } Remember:stdio.h> is for C;iostream> is for C++. Don't mix and match too much or you'll get warnings and/or errors. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049610 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 oh, I see... How am I supposed to know which one is for C and which one is for C++? But I get the same error with this code: Quote #include <iostream>int main(void) { cout <<< "Hol?"; return 0; } Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049791 Share on other sites More sharing options...
0 bluebsh Posted July 15, 2003 Share Posted July 15, 2003 the problem is that your operatior is "<<<" and not the correct "<<" change that and it will fix the problem remember these are the operators u have in c++ ! ~ + - * & / % << >> < <= > >= == != ^ | && || += -= *= /= %= &= ^= |= <<= >>= , ->* -> () [] = ++ -- new delete there is no "<<<" also you need a namespace do using namespace std; or useing namespace std::cout; Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049797 Share on other sites More sharing options...
0 Iluvatar Posted July 15, 2003 Share Posted July 15, 2003 try it with the "using namespace std;" at the top like in the post earlier and dont put three of the "<" signs on your cout statment only two that might be messing it up. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049803 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 But I keep getting the same error all the time... it won't even compile it. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049817 Share on other sites More sharing options...
0 Iluvatar Posted July 15, 2003 Share Posted July 15, 2003 (edited) did you create a project within borland? a few compilers reqiure a project to be created to store the source code in and will give errors if the source file is not contained within a project. I dont know specifically about borland though. Your code worked in Dev-CPP on my machine with "using namespace std;" and removing one of the three "<" you had in your cout statement. Is there a clean rebuild or rebuild all or something like that available in borland? sometimes i have noticed that if the compiler gives me an error and i fix it. then it still gives me the error because it didnt actually compile the new source file. Those options always fix it though. A wierd quirk i guess. Edited July 15, 2003 by Iluvatar Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049836 Share on other sites More sharing options...
0 bluebsh Posted July 15, 2003 Share Posted July 15, 2003 you need more then just the compiler exe to compile, you need all the header files too and such.. make sure you have all them Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049837 Share on other sites More sharing options...
0 Iluvatar Posted July 15, 2003 Share Posted July 15, 2003 #include <iostream> and 'using namespace std;' is really all that they would need for a simple statement like that Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049852 Share on other sites More sharing options...
0 bluebsh Posted July 15, 2003 Share Posted July 15, 2003 Iluvatar said: #include <iostream> and 'using namespace std;' is really all that they would need for a simple statement like that remember that he said with cpp32.exe, sounds like he's doing a command line compile. the paramaters need to be checked if this is the case, and that he has all the proper header files requried like iostream and such before the compile will work successfuly. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049859 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 I've used MASM before and I know what I need... no files missing. Read the error message! It complains about a file that I haven't written. And where do I put "using namespace std;", you just say "at the top blah blah"... I don't get it. I have no idea what the directive does. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1049956 Share on other sites More sharing options...
0 azcodemonkey Posted July 15, 2003 Share Posted July 15, 2003 just dl'ed the commandline compiler, configed it, and compiled and linked your code, no problem. How did you config the compiler and linker? Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050056 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 cpp32.cfg: -I"c:\Program\Borland\BCC55\Include" -L"c:\Program\Borland\BCC55\lib;c:\Program\Borland\BCC55\lib\psdk" ilink32.cfg: -L"c:\Program\Borland\BCC55\lib;c:\Program\Borland\BCC55\lib\psdk" Then I have Build.bat that I use when I compile: Quote @c:\program\borland\bcc55\bin\cpp32 -e"test.exe" "test.c"@pause bcc32.exe worked just fine... but I'm trying to write some C++ now. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050059 Share on other sites More sharing options...
0 azcodemonkey Posted July 15, 2003 Share Posted July 15, 2003 i think you need to drop the second lib path. this works just fine for me in both the cpp32.cfg and the ilink32.cfg. -L"c:\Program\Borland\BCC55\lib" I'll see if it breaks my stuff. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050068 Share on other sites More sharing options...
0 azcodemonkey Posted July 15, 2003 Share Posted July 15, 2003 ok... it doesn't break it. I'm perplexed. [edit] nevermind. i missed the cpp32 thing. so, why are you using that instead of bcc32? you can compile cpp with bcc32. am i missing something? cpp32 is a compiler preprocessor. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050075 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 bcc32 returns error too... Quote Fatal F1003 c:\Program\Borland\BCC55\Include\stdcomp.h 5: Error directive: Must use C++ for STDCOMP.H Doesn't like my file extension? Maybe it wants it to be .cpp instead of .c? :wacko: I changed file extension and works just fine... but what does "using namespace std;" do? Where do I put it, "at the top" isn't enough for me. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050171 Share on other sites More sharing options...
0 Oogle Posted July 15, 2003 Share Posted July 15, 2003 Hmm, didn't you see my code? It shows exactly where to put the using namespace std. Here it is again if you didn't see it the first time... #include <iostream> using namespace std; // <-- HERE IS WHERE YOU PUT IT int main(void) { cout << "Hol?"; return 0; } And your extension must be .CPP for this to work, because this is C++ code. If the compiler sees .C, it'll think it's C code and you'll run into problems. Namespaces basically avoids name conflicts. It's a C++ specific keyword. That statement tells the compiler that you're using code from the standard library (akastd>). Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050209 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 Oogle said: Hmm, didn't you see my code? It shows exactly where to put the using namespace std. Here it is again if you didn't see it the first time... #include <iostream> using namespace std; // <-- HERE IS WHERE YOU PUT IT int main(void) { ? cout << "Hol?"; ? return 0; } And your extension must be .CPP for this to work, because this is C++ code. If the compiler sees .C, it'll think it's C code and you'll run into problems. Namespaces basically avoids name conflicts. It's a C++ specific keyword. That statement tells the compiler that you're using code from the standard library (astd/b>). ah, OK. I knew what STD ment but I had no idea what the statement did. Thank:blush:sh: Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050389 Share on other sites More sharing options...
0 compSciDude21001 Posted July 15, 2003 Share Posted July 15, 2003 Dude, sounds like you just need to upgrade to Borland Visual C++ 6 . None of this would be happening there. Quote DON'T PUT THE .H AT THE END!!! Why? I allways put the .h at the end. I've never had a problem with it. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1050975 Share on other sites More sharing options...
0 azcodemonkey Posted July 15, 2003 Share Posted July 15, 2003 when you use the .H, you are using non-standard libraries. I think they are deprecated, as in "don't use these libraries unless you are supporting something really old." Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1051014 Share on other sites More sharing options...
0 Chadwick Posted July 15, 2003 Share Posted July 15, 2003 no, #include "iostream.h" means its not standard while #include <iostream.h> means it is. " " - not < > is and i spent htis whole schoolyear coding console c++ apps, u dont need that namespace thing #include <iostream.h> void main() { cout << "Hola" << endl; } will give hte same thing without ur special a character of course ;) Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1051097 Share on other sites More sharing options...
0 Tobbe Posted July 15, 2003 Author Share Posted July 15, 2003 I would like to have a fresh version of a compiler, but I ain't paying for it and I don't want some free but buggy compiler. I don't work as a programmer and I don't sell anything that I've done so there's no reason to pay for a compiler. All I want is a command line compiler, no fancy stuff. I've written thousands of lines in ASM just using notepad and I'm used to that. :) By the way, why does this code: #include <iostream.h> int main(void) { std::cout << "Hej hej!"; return 0; } ...take 112640 bytes when compiled? I've written a program in ASM that's about 3800 lines long, graphics etc. etc. and it's a 46kB EXE? Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1051263 Share on other sites More sharing options...
0 Chadwick Posted July 16, 2003 Share Posted July 16, 2003 the libraries, iostream probably calls on 3 or so more librarys which probably call on others, so in turn you can be writing a 5 line program that has 3000 lines of code from '.h' files unseen to you. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1051554 Share on other sites More sharing options...
0 compSciDude21001 Posted July 16, 2003 Share Posted July 16, 2003 Quote and i spent htis whole schoolyear coding console c++ apps, u dont need that namespace thingI noticed the same thing, I have never used a namespace, and everything has worked just fine. Quote I don't work as a programmer and I don't sell anything that I've done so there's no reason to pay for a compiler. Are you a student. .. . I got my from my school store for $99. That was Borland 5! Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1051983 Share on other sites More sharing options...
0 Tobbe Posted July 16, 2003 Author Share Posted July 16, 2003 Chadwick 08 said: the libraries, iostream probably calls on 3 or so more librarys which probably call on others, so in turn you can be writing a 5 line program that has 3000 lines of code from '.h' files unseen to you. Does it include all content from all the header files? Because that doesn't make sence. :wacko: Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1052559 Share on other sites More sharing options...
0 Oogle Posted July 16, 2003 Share Posted July 16, 2003 Chadwick 08 said: no, #include "iostream.h" means its not standard while #include <iostream.h> means it is. " " - not < > is " " and < > have nothing to do with how "standard" a file is. " " means "get the file located between the quotes". It also accepts paths relative to your project folder. < > means "search the default include paths for this file". Paths are relative to the default include paths, which are determined by your project settings. Default means project defaults; not standard defaults. iostream.h and iostream are 2 completely different files. Do a file search and see for yourself. Like weenur said, iostream.h is deprecated. iostream contains the implementation from the standard library. Quote I noticed the same thing, I have never used a namespace, and everything has worked just fine.All you're doing is running the risk of using a cout that's not part of the standard library. Whether or not that risk is acceptable to you fully depends on the requirements of your project. The using namespace std statement just ensures that you're using the cout from the standard library. Quote I've written a program in ASM that's about 3800 lines long, graphics etc. etc. and it's a 46kB EXE? In general, C++ gives you code maintainability and high-level abstraction at the cost of size and low-level optimization. If a smaller EXE is of the utmost importance, then you should probably stick to ASM. Quote QUOTE (Chadwick 08 @ Jul 16 2003, 03:35)the libraries, iostream probably calls on 3 or so more librarys which probably call on others, so in turn you can be writing a 5 line program that has 3000 lines of code from '.h' files unseen to you. Does it include all content from all the header files? Because that doesn't make sence. Header files usually take up very little space when compiled into code (unless you're inlining a lot of stuff). What takes up the bulk of the space are the libraries and object files that your program files link to. A good linker will usually leave out files that your cpp files don't call into. Also note that if you use debug libraries instead of release libraries, your executable will be much larger. Link to comment https://www.neowin.net/forum/topic/92199-c-compile-error/#findComment-1052979 Share on other sites More sharing options...
Question
Tobbe
I downloaded Borlands C++ Compiler 5.5 and when I'm about to compile a file with cpp32.exe then I get error.
My code:
The error:Why aren't the definitions identical?
Link to comment
https://www.neowin.net/forum/topic/92199-c-compile-error/Share on other sites
25 answers to this question
Recommended Posts