Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ric63 on January 15, 2012, 11:14:25 AM

Title: how to compile c++ programm
Post by: ric63 on January 15, 2012, 11:14:25 AM
Hi,
I am an beginner to c++. I installed Code::Block under Ubuntu and I writted a simple program that work.
I now would make a library for Ubuntu.
When I make a new project -> static library, I see a .c file and not .cpp file.
Why ?
Title: Re: how to compile c++ programm
Post by: Alpha on January 15, 2012, 06:27:00 PM
All C code is valid C++ code; you could rename the file extension (it probably will need to be re-added to your project).
Alternatively, you could delete the C file and add however many C++ files you want.  The structure of code in a static library is not nearly as strict as in other areas because it is simply a collection of object files waiting to be linked at a later point in time.

You do have a valid point though; for continuity, the static library wizard should have a language selection page...
Title: Re: how to compile c++ programm
Post by: ric63 on January 15, 2012, 07:25:47 PM
thanks.
it work
I have deleted the .c file and added .cpp file.
So, I have builded the static library.
bye
Title: Re: how to compile c++ programm
Post by: zabzonk on January 15, 2012, 07:44:44 PM
QuoteAll C code is valid C++ code

This is very, very far from true.
Title: Re: how to compile c++ programm
Post by: Alpha on January 15, 2012, 08:35:18 PM
Quote from: Neil Butterworth on January 15, 2012, 07:44:44 PM
QuoteAll C code is valid C++ code

This is very, very far from true.
Example/link??
Title: Re: how to compile c++ programm
Post by: zabzonk on January 15, 2012, 08:49:25 PM
Well, a couple of simple examples:

// valid C code not valid C++
int main() {
     int new = 0;
     char * p = (void *) 0;
}


But there are  a lot more.
Title: Re: how to compile c++ programm
Post by: stahta01 on January 15, 2012, 09:05:08 PM
http://david.tribble.com/text/cdiffs.htm#C++-vs-C (http://david.tribble.com/text/cdiffs.htm#C++-vs-C)

Tim S.
Title: Re: how to compile c++ programm
Post by: Alpha on January 15, 2012, 09:48:13 PM
Thanks.

I should have expected I would miss something obvious, having learned to program by means of Google and reading source (like Code::Blocks!) in my free time over the past year and a bit.  (But you may already have guessed at my inexperience if you looked at my style in the patches I have submitted.)

I still have much to learn...