Re: strings and char *

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bob Rossi wrote:

> On Thu, Aug 10, 2006 at 02:00:59PM -0400, Michael Surette wrote:
>> It's been a while since I've written any C code, so please forgive me if
>> this is a newbie type question.
>> 
>> I was having a problem with a larger program when I ran into a problem. 
>> The following code snippet should work according to what I remember of C.
>> What's wrong with it?
>> 
>> ------------
>> 
>> char * color;
>> char * r="red";
>> color = r;
> 
> Is that at the global scope? You can't make assignments in the global
> scope unless they are definitions as well. Try putting that code in a
> function scope.
> 
> Bob Rossi

Thanks for the quick response.  That fixed it.  That would be one of those
many changes to the C language over the years I guess.  What threw me off
was that it compiled fine for my brother, who runs a Windows based
compiler.

As I mentioned in my original posting, I wrote that snippet because I was
having a problem with a larger program, a glue program between lua and
sendmail's milter interface.  Perhaps you can help me with that?

I have a function defined as...

static sfsistat callback(SMFICTX *ctx, char *cbname, char *cbargs[]);

later in the code, I call it (one of many times)...

return callback(ctx, "helo", {helohost,NULL});

where...

ctx is a SMFICTX * supplied by sendmail
"helo" is obviously a character string
helohost is a char * provided by sendmail

When I try to compile I get the error message...

luamilter.c:137: error: parse error before '{' token

Is this another of those many changes over the years that I missed?

Mike




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux