Mundane C tricks ...

Discuss programming topics for the various GPL'd game engine sources.
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: Mundane C tricks ...

Post by taniwha »

Ah, yes, memset and C++ objects is dangerous (more charred fingers). I learned to go very carefully though the list of fields in my constructors.
Leave others their otherness.
http://quakeforge.net/
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Post by revelator »

The code was allready there from stock ID source so might have been an oversight when they started porting stuff from C to C++ ;)
atleast its Things that teach you to be very carefull not to treat OO code the same as C hehe.
I learn a bit more every day and while most C operations are also valid in C++ there are a few differences like the
beforementioned example that one has to be aware of.

And merry Christmas all :)
Productivity is a state of mind.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Post by Baker »

I just discovered printf "%g". I swear I've read printf formatting docs a million times.

It is rather difficult to identify which version of C it became a standard, so maybe this format specifier didn't always exist or something.

%g prints a float, but without the superfluous zeros 1.000000000000000000000

/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
taniwha
Posts: 401
Joined: Thu Jan 14, 2010 7:11 am
Contact:

Re: Mundane C tricks ...

Post by taniwha »

Yeah, %g is nice. QF has been using it for a while (especially in that builtin that goes to pains to strip trailing 0s). I've almost forgotten %f exists :).
Leave others their otherness.
http://quakeforge.net/
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Mundane C tricks ...

Post by frag.machine »

Baker wrote:/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
Yeah, got same problem here, I was thinking I3D hated my Opera mobile but since I am not the only one having a hard time to login maybe someone could check what's wrong.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Post by Baker »

frag.machine wrote:
Baker wrote:/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
Yeah, got same problem here, I was thinking I3D hated my Opera mobile but since I am not the only one having a hard time to login maybe someone could check what's wrong.
The skygods are testing us, to see if we are worthy. Zeus and his friends are having a laugh right now, at our expense ...
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Post by revelator »

Heh recently discovered %p for printing pointers, somewhat weird experience since earlier msvc newer bitched about using any of the other print types but msvc2012 seems to have taken a new approach (%p also Works in msvc2010 but i havent tried in earlier versions yet).

Kinda hope clang catches up and will be supported by C::B its error checking is a revelation compared to gcc's but speedwise it still lacks some compared and it has no own standard library yet that im aware of so it uses gcc's.
Productivity is a state of mind.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Post by Baker »

reckless wrote:Heh recently discovered %p for printing pointers
I've had better luck at locating good printf tricks in recent times like printf ("%-20.20s", fixed_length_printing_string);

Or %x, even %c
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply