Curiosity, (Coding c, C++)

Do you need help? Ask here!

Bug reporting belongs here: http://developer.wz2100.net/newticket
Post Reply
User avatar
craigengbrecht
Trained
Trained
Posts: 51
Joined: 21 Jul 2008, 03:49
Location: Red Deer, AB
Contact:

Curiosity, (Coding c, C++)

Post by craigengbrecht »

As I am very new to coding, is it possible to run C code (the main part of the game) and C++ code running the sound engine? are they compatible working together or is this impossible?
AMD FX X8 3.88Ghz
16GB KVM 1333Mhz
ASUS M5A97
ASUS EAH 6850 1GB
3x ASUS 1920x1080 VW246H
1x 5000GB Primary
1x 1TB Internal
1x 3TB Internal
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Curiosity, (Coding c, C++)

Post by Chojun »

Yes, this is possible, with a little fancy coding. Nothing too serious, but a deeper understanding of how C and C++ works will help you in your efforts. (In other words, programmers new to either language probably wouldn't be able to do it).
User avatar
craigengbrecht
Trained
Trained
Posts: 51
Joined: 21 Jul 2008, 03:49
Location: Red Deer, AB
Contact:

Re: Curiosity, (Coding c, C++)

Post by craigengbrecht »

Got ya, But if I were able to learn and make it work, at least it is something I can strive for and work with.
I may be learning but a challenge is always welcome.
AMD FX X8 3.88Ghz
16GB KVM 1333Mhz
ASUS M5A97
ASUS EAH 6850 1GB
3x ASUS 1920x1080 VW246H
1x 5000GB Primary
1x 1TB Internal
1x 3TB Internal
User avatar
Zarel
Elite
Elite
Posts: 5770
Joined: 03 Jan 2008, 23:35
Location: Minnesota, USA
Contact:

Re: Curiosity, (Coding c, C++)

Post by Zarel »

Chojun wrote:Yes, this is possible, with a little fancy coding. Nothing too serious, but a deeper understanding of how C and C++ works will help you in your efforts. (In other words, programmers new to either language probably wouldn't be able to do it).
And here I thought C++ was back-compatible with C. Wouldn't it be enough just to say "This is C++ now!" on the C code and have it work?
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Curiosity, (Coding c, C++)

Post by Chojun »

C is a subset of C++, so in theory it is possible to compile C code as C++ code and everything works. However, the two have been drifting apart over the last few years, so if you flip that compiler switch you may get a (large) number of small errors that need to be resolved.
User avatar
Zarel
Elite
Elite
Posts: 5770
Joined: 03 Jan 2008, 23:35
Location: Minnesota, USA
Contact:

Re: Curiosity, (Coding c, C++)

Post by Zarel »

Chojun wrote:C is a subset of C++, so in theory it is possible to compile C code as C++ code and everything works. However, the two have been drifting apart over the last few years, so if you flip that compiler switch you may get a (large) number of small errors that need to be resolved.
Yes, but we aren't using the drifted-apart versions - I think the '//' is one of the few C99 features we use, and that's definitely C++ compatible.
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Curiosity, (Coding c, C++)

Post by Chojun »

You will have issues compiling C code as C++ code, especially the Warzone source.
cumandgetit
Trained
Trained
Posts: 103
Joined: 06 Feb 2009, 04:02

Re: Curiosity, (Coding c, C++)

Post by cumandgetit »

you may find what follows of some use in your studies.

started with c and found kernighan and ritchie's "the ansi c programming language" 2nd edition enjoyable (to my surprise) as much as edifying.

moved on to c++ (& script code based on) where i am currently entrenched. the work i found both delightful and extremely useful was (is)
"thinking in C++" (2nd Edition) in 2 volumes by Bruce Eckel (you can get as a no charge .pdf download & save your self a hundred bucks).

lastly, a work whose usefulness transcends particular languages (while using examples in c, c++, c#,vb, java and so on) that you should, i strongly feel, fully absorb, is called: "code complete: a practical handbook of software construction" by Steve McConnell. the lessons in this work are essential to a pro mastery, imho. an indispensable classic.

all good things, bud :)
:lecture:

"Almost all our faults are more pardonable than the methods we resort to, to hide them." - Duc de la Rochefoucauld
User avatar
craigengbrecht
Trained
Trained
Posts: 51
Joined: 21 Jul 2008, 03:49
Location: Red Deer, AB
Contact:

Curiosity, (Coding c, C++)

Post by craigengbrecht »

Wow, the things you can learn in one week!
Thanks for all the tips guys, they will help speed my learning!
AMD FX X8 3.88Ghz
16GB KVM 1333Mhz
ASUS M5A97
ASUS EAH 6850 1GB
3x ASUS 1920x1080 VW246H
1x 5000GB Primary
1x 1TB Internal
1x 3TB Internal
EvilGuru
Regular
Regular
Posts: 615
Joined: 23 Jun 2007, 22:41

Re: Curiosity, (Coding c, C++)

Post by EvilGuru »

It is more than possible to write the sound engine in C++, so long as you provide a C interface for it. So as long as all of the functionality can be accessed from C (using extern "C" { ... } in the header file to ensure that C-style linking is used) then there is no problem.

Regards, Freddie.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Curiosity, (Coding c, C++)

Post by Per »

Since we do not have a C++ coding style document, and any collaborative C++ project is hopelessly lost without it, I think it would be wise to stick to C for now. Otherwise you might get bogged down with questions far removed from those you were supposed to solve.
User avatar
Buginator
Professional
Professional
Posts: 3285
Joined: 04 Nov 2007, 02:20

Re: Curiosity, (Coding c, C++)

Post by Buginator »

Chojun wrote:You will have issues compiling C code as C++ code, especially the Warzone source.
That sure is a understatement. :stressed:
and it ends here.
Post Reply