I'm running from command line. I know how to set QUERY_STRING as an env var, but I don't get how the strcmps can work. See the 1st strcmp. It checks to see if Args is exactly equal to "Height". If it...
Type: Posts; User: homer_3
I'm running from command line. I know how to set QUERY_STRING as an env var, but I don't get how the strcmps can work. See the 1st strcmp. It checks to see if Args is exactly equal to "Height". If it...
I'm trying to understand this open source code I found here: http://www.lysator.liu.se/~johol/fwmg/source/WorldMapGenerator.c.
I cannot figure out how to pass arguments to the program. I know I...
Thanks. Found this write up on that flag. https://gcc.gnu.org/wiki/NewWconversion. Unfortunately, my compiler is 4.1 so it seems like I may not have this option.
I always forget which one has stricter rules (C or C++) but shouldn't this give a warning in at least one of the languages?
int x = 120000;
short y = x;
I've tried compiling with both c...
Your standard cross-platform stuff. The API to do something on one platform isn't always the same as the API to do it on the other platform. So FOO is really more like PLATFORM and BAR is more like...
Say I have something lke
#define FOO BAR
#if FOO == BAR
doX();
#else
doY();
#endif
I've seen this said a lot too. But I don't see why using a mutex around accessing a shared resource would help. AFAIK, all using a mutex does is ensure exclusive access to it. But if the compiler...
I'm trying to figure out if I need to use volatile or not. All of the examples I've seen so far seem to be set up as some small loop is checking the state of a variable to see if it should exit the...
I noticed that when using variadic functions, if I pass the va_arg() as parameter to a function, the parameters get passed in reverse. Is that expected?
For example, the following code outputs
...
The unsigned cast of a float. A signed cast works ok.
I'm trying to cast a float to an unsigned int and getting some surprising behavior.
float x = -1.0;
unsigned int y = (unsigned int)x;
printf("y = %d\n", y);
The output of this code...
So, like usual, even though I spent 45 making my post and thinking about other ways to solve the issue before posting, it's not until just after I post that I solve the problem. I forgot that...
Let's say I have a log function
void my_log(char * msg, unsigned int arg)
{
char buf[500];
snprintf(buf, 500, msg, arg);
printf(buf);
Why do they have to make my life so hard! Thanks though, good info to know.
It looks like smokey has the best solution. I think I can work with that, thanks!
Wow, you're upset. I did give a very specific example. Why would there be an expectation that the example could be changed in order to solve the problem?
It'd due to general limitations. I need a way to output some numeric identifier for the class field. The offset from the start of the class seems like the best identifier to me.
Would be nice,...
So I obviously can't take the address of a bitfield, but is there a way to get the address of the field holding the bitfield? What I'm trying to do is find the address of the parent field of a...
So is this implementation defined or maybe just a difference between C and C++? My C compiler prints out -1 and -2 where the C++ results in the 31/6. I also thought that the fact that the value is a...
Of course there are enough bits. What makes you say there aren't enough bits? 2's compliment works fine with 2 bits or more. 11111 - 1 = 11110. ~11110 = 00001.
11111 is -1 when converted to int using 2's complement. Likewise 11110 is -2 when converted to int using 2's complement. This is why I'm confused about the output.
Yes, exactly. Printing as a...
I'm getting unexpected output in 2 different cases. The 1st deals with bitfields. The C++ standard has this line about integral promotions:
This sounds like the value of a bitfield will always...
Mods, close this thread if you can. I was running this on a fresh install of CentOS and forgot to turn my firewall off! I didn't realize tcpdump could pick up packets before the firewall.
I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never...
Actually, I found I was off by a power of 10 in my measurement, so it's not as big an issue as I thought.
Well crap. After profiling, the map lookup is too slow :( So I guess it's back to trying to figure out why what I have crashes.