ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have an issue when compiling a program in cpp. The specific error is:
test.cpp: In function "int main()" :
test.cpp:11: error: aggregate "std::string value" has incomplete type and cannot be defined
I'm using Fedora Core 7 with kernel-2.6.21-1.3194.fc7 and I'm using gcc-4.1.2-27.fc7. I'm compiling the following program with the command:
gcc -o test.exe test.cpp
Any clues would be greatly appreciated.
using namespace std;
value = "Hello World";
It compiles and runs fine without "#include <string>" (on my machine with gcc 4.1.2, anyway).
First and foremost, even if it does, itís wrong. There is nothing special about strings that allows their use without their definition, and their is nothing special about namespace std (in fact, namespace std does not exist without the standard library headers). See ß22.214.171.124.
Second, are you sure? Whose gcc do you have? For me, it throws an error with (and most of these are near-vanilla) g++-3.4.6, g++-4.1.2, and g++-4.2.2.
Also, there is a separate issue (probably) not present in the original post. When you #include certain standard headers, they end up including others. This behavior is expressly permitted by the standard (ß126.96.36.199). The only problem is it is not specified what headers include other headers except that a header must include another header if it contains a needed definition. So free rein is given to implementors on what headers can include what other headers. For example, with most g++ implementations, if you #include <iostream>, you have implicitly #included <string> as well. Except for the unlikely event that your <vector> header #includes <string>, I donít see how your implementation successfully compiles the original program. This gets to limit the portability of compiling a program, since some implementors chose differing headers to be included by other headers. As such, the next version of g++ (4.3 branch) will strive to eliminate all unnecessary headers inclusion of other headers. If that happens, a program which successfully compiles with g++ will be guaranteed (at least in that respect) to compile on any other conforming compiler.