[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Mundane C tricks ...

Mundane C tricks ...

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Re: Mundane C tricks ...

Postby revelator » Fri Dec 14, 2012 2:32 am

Mostly i would agree but in the case i had it was something that translated to {const char,const char, const char, huge cast to null terminate this array of strings} in turn it would translate to {const char, const char, const char, 0} so i was wondering why not just use the null string '\0' instead of the huge cast since its an array of strings wouldnt that be more correct ? or am i missing something. Ofc i would newer use the null string for a non char pointer :) that would be silly.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2605
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Postby taniwha » Fri Dec 14, 2012 4:31 am

95% of the time, I couldn't care less what a variable's type is, which is a large part of the reason I despise Hungarian notation (*twitch*, *twitch*, *bleh*, I feel dirty just saying it :mrgreen:).

I don't know, maybe it's just something that comes with programming for 30 years (20 of which in C or C++), in a variety of fields (2d and 3d graphics, 2d and 3d physics, compilers, networking). After a while, beyond telling the compiler how the data is to be handled (eg, int vs float), type becomes meaningless. I don't think in terms of pointers and structs, I think in terms of "I've got this thing here, with these named features". Might be part of why I always get my . and -> mixed up :) (another part is python and qfcc (I didn't bother with ->, though I might add it as an option)).

Having to think about type ('\0' for char, 0 for int, 0.0 for float, NULL for pointers) would only get in the way (ouch, my head hurt just filling in the examples), just like having to get . and -> right does (and I read somewhere that either Kernighan or Ritchie (don't remember) regrets ->). I am very grateful that C always treats 0 of any type as false and non-zero of any type as true, and that just a bare 0 works for any non-aggregate type. The compiler gets out of the way and lets the programmer concentrate on the problem the code is to solve rather than futzing with trivial details.

Actually, I have a good argument against using '\0': it can be visually confused with '0', or worse, '10' (sure, gcc will warn about that one, but...). I think I read that somewhere in some style guide. Oh, and a second one: what is '\013'? :)
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Mundane C tricks ...

Postby Baker » Fri Dec 14, 2012 6:59 am

Last edited by Baker on Fri Dec 14, 2012 7:01 am, edited 1 time in total.
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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Postby revelator » Fri Dec 14, 2012 7:01 am

Heh true it can be a bit confusing :) atleast 0 is allways equal to none and doing things with an escaped string type might be rather hard to compute. Im not 100% on it but i think \013 would translate to 0.13 but is it a positive value ??? hmm probably though im not sure how to do a negative value with a string type like that unless char > '\stringvalue' or does it accept a - ? hmm. In that case i would probably prefer just using plain 0.13 ;)

I guess my style comes from not having learned neither C nor C++ professionally its just things i picked up over the years and theres a lot of holes still to be filled but mostly i can get things working though if i had to do it for a living i would probably starve to death :lol: im not exatly fast but i do the best with what i got. Only language i actually invested heavily in was basic back when the spectrum zx80 and amigas where the thing today i can remember two things from all that (jack and shit) :mrgreen: i guess when you dont use use a skill everyday it tends to go blank hehe.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2605
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Postby revelator » Fri Dec 14, 2012 7:08 am

Totally agree baker :) if someone can use my ideas who am i to argue when i got so much in return i feel obliged to atleast leave a footprint of what i learned from all of it and if it benefits others all the better.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2605
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Postby szo » Fri Dec 14, 2012 7:45 am




szo
 
Posts: 132
Joined: Mon Dec 06, 2010 4:42 pm

Re: Mundane C tricks ...

Postby taniwha » Fri Dec 14, 2012 7:56 am

Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Mundane C tricks ...

Postby revelator » Fri Dec 14, 2012 9:59 am

hehe :) ok no hungarian notations noted.
is'nt hex octal by nature ? though a hex number as a string terminator would probably make my head explode :P be gentle on the old hobby programmer here hehe.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2605
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Mundane C tricks ...

Postby taniwha » Sat Dec 15, 2012 4:47 am

Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Mundane C tricks ...

Postby Baker » Sat Dec 15, 2012 2:51 pm

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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Postby taniwha » Sun Dec 16, 2012 5:53 am

Yeah, well, strong claims need strong support, to paraphrase the quote about proof.

However, I'm not so much about convincing someone I'm right as I am about getting the person to understand my claims and why I make them, giving them an opportunity to point out where I'm wrong (if I am, which is not guaranteed). Unfortunately, not many people see it that way :(.
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Mundane C tricks ...

Postby Baker » Tue Dec 18, 2012 1:20 pm

I've started getting rather heavy into linked-lists. And to my surprise there, I've discovered that with parent/peer/child structure there are multiple ways you can need to traverse them.

I'm gunning for the oddball ability to save every possible user interface item and entities into the same file. With the ability to have multiple 3D viewports and an interface editor that can work with the data and dragable elements.

I'm also doing something possibly unwise with the display, penetrating through levels of parents/child to be able to calculate real hardware X, Y for "virtual points" in a viewport and setting up windows in such a way that the screen may have the window centered.

At the moment: I am frustrated. :D

/But isn't that just part of working on complex stuff in programming. :mrgreen: :mrgreen: If I gave up easily, hahaha ... you can't code stuff at all ... and you don't have this issue with great frequency then one must not be doing anything fun ...
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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Postby taniwha » Wed Dec 19, 2012 2:29 am

Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Mundane C tricks ...

Postby Baker » Wed Dec 19, 2012 6:07 am

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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Mundane C tricks ...

Postby Baker » Wed Dec 19, 2012 6:10 am

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 ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

PreviousNext

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests