Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5211

Re: Unexpected Difficulty with String Constant Concatenation

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Unexpected Difficulty with String Constant Concatenation
Date 2011-06-01 10:07 -0700
Organization None to speak of
Message-ID <lnd3ixmqem.fsf@nuthaus.mib.org> (permalink)
References <jqqcu69ug4eo4fd1b97qj75engnaogon2b@4ax.com>

Show all headers | View raw


Datesfat Chicks <datesfat.chicks@gmail.com> writes:
> This code:
>
>    #define CONFIG_BEHAVIOR_H_VERSION ("$Header:
> /var/lib/cvs/ceq_ceqpctls/ceqpctls/prf_tm_data_collect/prog/prf_tm_data_expand/prf_tm_data_expand/config_behavior.h,v
> 1.1 2011/06/01 16:40:53 dashley Exp $")
>
> const char *C_MAIN_cvcinfo(void)
>    {
>    return
>       (
>       "$Header:
> /var/lib/cvs/ceq_ceqpctls/ceqpctls/prf_tm_data_collect/prog/prf_tm_data_expand/prf_tm_data_expand/c_main.c,v
> 1.6 2011/06/01 16:40:14 dashley Exp $"
>       CONFIG_BEHAVIOR_H_VERSION
>       );
>    }
>
> won't compile and gives this error message.
>
> c_main.c(71): error C2064: term does not evaluate to a function taking
> 305 arguments

I presume the string literal "$Header: ... Exp $" is actually on one
very long line in your program.  In your posted article, it's split
across 3 lines.  It would be good to mention this; I briefly assumed
that you were trying to use a multi-line string literal.

(I think your question has been answered.)

> However, if I change the preprocessor constant to omit the
> parenthesis:
>
>    #define CONFIG_BEHAVIOR_H_VERSION "$Header:
> /var/lib/cvs/ceq_ceqpctls/ceqpctls/prf_tm_data_collect/prog/prf_tm_data_expand/prf_tm_data_expand/config_behavior.h,v
> 1.1 2011/06/01 16:40:53 dashley Exp $"
>
> it works fine.
>
> Question:  what is going on at the parser and compiler level?
>
> I suspect that when I parenthesize the constant it means something
> different so that it can't treat it as string concatenation.

Concatenation of string literals applies only to literals.  A literal in
parentheses is a valid expression, but it's not a literal.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Unexpected Difficulty with String Constant Concatenation Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-06-01 12:45 -0400
  Re: Unexpected Difficulty with String Constant Concatenation Billy Mays <noway@nohow.com> - 2011-06-01 12:49 -0400
    Re: Unexpected Difficulty with String Constant Concatenation Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-06-01 13:19 -0400
  Re: Unexpected Difficulty with String Constant Concatenation blp@cs.stanford.edu (Ben Pfaff) - 2011-06-01 09:50 -0700
  Re: Unexpected Difficulty with String Constant Concatenation Kenneth Brody <kenbrody@spamcop.net> - 2011-06-01 12:56 -0400
    Re: Unexpected Difficulty with String Constant Concatenation blp@cs.stanford.edu (Ben Pfaff) - 2011-06-01 09:59 -0700
      Re: Unexpected Difficulty with String Constant Concatenation Kenneth Brody <kenbrody@spamcop.net> - 2011-06-02 11:07 -0400
        Re: Unexpected Difficulty with String Constant Concatenation Kenneth Brody <kenbrody@spamcop.net> - 2011-06-02 11:22 -0400
        Re: Unexpected Difficulty with String Constant Concatenation Shao Miller <sha0.miller@gmail.com> - 2011-06-02 11:25 -0500
        Re: Unexpected Difficulty with String Constant Concatenation Ben Pfaff <blp@cs.stanford.edu> - 2011-06-02 09:02 -0700
          Re: Unexpected Difficulty with String Constant Concatenation Kenneth Brody <kenbrody@spamcop.net> - 2011-06-03 10:49 -0400
        Re: Unexpected Difficulty with String Constant Concatenation "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-03 01:52 +0100
          Re: Unexpected Difficulty with String Constant Concatenation Keith Thompson <kst-u@mib.org> - 2011-06-02 18:06 -0700
  Re: Unexpected Difficulty with String Constant Concatenation Keith Thompson <kst-u@mib.org> - 2011-06-01 10:07 -0700
  Re: Unexpected Difficulty with String Constant Concatenation Stephen Sprunk <stephen@sprunk.org> - 2011-06-01 13:14 -0500

csiph-web