gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > I Yeti3d c or c++ ?

#71315 - bmnb1234 - Sat Feb 11, 2006 9:04 pm

Hi
I have a question all my experience is in C++. I been coding for years . I hate ask but is yeti 3d a c or c++ app It has a c extension but In Derek's commits "but that will
be after im 100% sure the C++ is as fast as it can be.". Looking at the code I am not sure.
Could some one clarify this for me please?

#71347 - josath - Sun Feb 12, 2006 12:44 am

You have years of experience with C++, but can't tell if you are looking at C++ code or not?

#71353 - Darkflame - Sun Feb 12, 2006 12:56 am

josath wrote:
You have years of experience with C++, but can't tell if you are looking at C++ code or not?


If he knows one, but never used the other, then compareing the two would be hard.

#71365 - keldon - Sun Feb 12, 2006 3:36 am

Darkflame wrote:
josath wrote:
You have years of experience with C++, but can't tell if you are looking at C++ code or not?


If he knows one, but never used the other, then compareing the two would be hard.

Yes, very true. Knowing C++ inside out and top to bottom does not tell you any of the features of C. C does not have:
# anonymous unions
# classes
# constructors and destructors
# exceptions and try/catch blocks
# external function linkages (e.g., extern "C")
# function overloading
# member functions
# namespaces
# new and delete operators and functions
# operator overloading
# reference types
# standard template library (STL)
# template classes
# template functions
# local variable declarations within conditional expressions (e.g. for ( int i ...)
# token spellings, e.g. (and for &&, and and_eq for &=)

For more information see http://david.tribble.com/text/cdiffs.htm#intro

#71401 - tepples - Sun Feb 12, 2006 4:15 pm

keldon wrote:
Knowing C++ inside out and top to bottom does not tell you any of the features of C. C does not have:
# anonymous unions

Feature may be provided by C compiler implementors as an extension to the C language.

Quote:
# external function linkages (e.g., extern "C")

This is already a common language extension. Specifically, I've seen 'extern pascal' in a lot of old code for Macintosh and Apple IIGS as well as 'fastcall', 'syscall', 'stdcall', and 'interrupt' on various platforms.

Quote:
# local variable declarations within conditional expressions (e.g. for ( int i ...)

This feature has made it into the latest version of C (nicknamed C99).

Quote:
# classes

'class' is largely a synonym for 'struct' anyway. The major difference is whether methods are allowed.

Quote:
# token spellings, e.g. (and for &&, and and_eq for &=)

Did somebody say #define?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#71403 - keldon - Sun Feb 12, 2006 4:45 pm

http://david.tribble.com/text/cdiffs.htm#intro

tepples wrote:
Quote:
# classes

'class' is largely a synonym for 'struct' anyway. The major difference is whether methods are allowed.
Did somebody say #define?


Yes, but classes also have destructors and empty constructors; and yes for the defines.

I was being quite general with this list; well actually it was all copied from that link. Still got problems with 'for (int i' in one of my c compilers; maybe one of the gb(a)dev compilers.

#71430 - sajiimori - Sun Feb 12, 2006 9:45 pm

To clarify, the struct and class keywords are exactly equivalent in C++, except that struct defaults to public and class defaults to private.

In C++, types declared using struct can have member functions. The compiler will also generate default constructors, destructors, copy constructors, and assignment operators for types declared using struct.

#71439 - keldon - Sun Feb 12, 2006 10:58 pm

Oh sorry; my mistake. I never knew that.

#73712 - bmnb1234 - Mon Feb 27, 2006 7:20 pm

I apresiate the respones I thought it looked c++ the c extention just though me off. Why anyone would wite c++ code in file with a c extention is beyound me
thanks!
Jason