[wplug] C compiling question
bpmedley at 4321.tv
bpmedley at 4321.tv
Tue Oct 1 01:26:40 EDT 2002
On Tue, 1 Oct 2002, James O'Kane wrote:
> Did something like this ever work as expected with any version of gcc? I
> found this code in mod_throttle, an apache module to add quotas to remote
> users. I'm surprised that it is being distributed because at least for
> me, it doesn't do what I would want. I've changed things to strcmp(), so
> I'm all set in terms of getting it to work, but I'm curious if gcc ever
> compiled this so it would work?
>
> static const char true[] = "true";
> char *foo = NULL;
>
> foo = setfoo();
>
> if(foo == true){
> // do stuff if foo is true
> }
The following code works for me. I'm using gcc 2.96 (the one that comes w/
rh 7.3). What makes you think that it wouldn't work?
*** begin code ***
#include <stdio.h>
static const char true[] = "true";
char *setfoo(void);
int main(void)
{
char *foo = NULL;
foo = setfoo();
printf("foo: %p - true: %p\n", foo, true);
if(foo == true){
printf("equal\n");
} else {
printf("not equal\n");
}
}
char *setfoo(void)
{
return (char *) &true[0];
}
*** end code ***
--
~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-., \|/ (___) \|/ _,.-=~'`^`
Brian Medley @~./'O o`\.~@
"Knowledge is Power" brian.medley at verizon.net /__( \___/ )__\ *PPPFFBT!*
-- Francis Bacon `\__`U_/'
_,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~= <____|' ^^`'~=-.,__,.-=
~`'^`'~=-.,__,.-=~'`^`'~=-.,__,.-=~'`^`'~=-.,__,.-==--^'~=-.,__,.-=~'`^`
More information about the wplug
mailing list