News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

how to compile c++ programm

Started by ric63, January 15, 2012, 11:14:25 AM

Previous topic - Next topic

ric63

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 ?

Alpha

#1
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...

ric63

thanks.
it work
I have deleted the .c file and added .cpp file.
So, I have builded the static library.
bye

zabzonk

QuoteAll C code is valid C++ code

This is very, very far from true.

Alpha

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??

zabzonk

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.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Alpha

#7
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...