[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2112.0. "char *c = "w" x y "z"; ?" by BALZAC::KUOCH () Thu Mar 06 1997 08:03

Hello,

    Is there an easy way to replace the following string concatenation code ?

       char *str_var = "CONSTANT_1" __DATE__ __TIME__ "module_name" DESCRIPT ;

       __DATE__ and __TIME__ : compilation date and time, defined by compiler
       DESCRIPT is defined with cc -DDESCRIPT=\"xxxx\"

    I encounter this kind of char declaration while porting an application
    from IBM and BULL to DIGITAL UNIX.

    DEC C compiler requires a ";" after "CONSTANT_1"
    The partner says that it run with IBM and BULL.

    Of course, sprintf can concatenate these strings, but the declarations
    are in 158 .h files, so I look for some thing simpler.
 
    I tried :
    	#define TEST "\"CONSTANT_1  __DATE__  __TIME__ module_name DESCRIPT \""
    	char *str_var = TEST;
    but no succes .

    Do you have any suggestions ?

    Thank in advance.
Cheu.
    
T.RTitleUserPersonal
Name
DateLines
2112.1can you give more info?MUCTEC::BECKERHartmut B., VMS & Languages, MunichThu Mar 06 1997 09:1018
Can you supply more information? With DEC C V4.2-002, aka cc -migrate, it works
as expected on our system:
                 
nasaxp.rto.dec.com> cat foo.c
char *str_var = "CONSTANT_1" __DATE__ __TIME__ "module_name" DESCRIPT ;
nasaxp.rto.dec.com> cc -migrate -c -DDESCRIPT=\"xxxx\" foo.c
nasaxp.rto.dec.com> cc -migrate -E -DDESCRIPT=\"xxxx\" foo.c
# 1 "foo.c"
char *str_var = "CONSTANT_1" "Mar  6 1997" "14:57:34" "module_name" "xxxx" ;
nasaxp.rto.dec.com> uname -a
OSF1 nasaxp.rto.dec.com V3.2 214.61 alpha

If a ';' is expected after "CONSTANT_1" I assume __DATE__ isn't replaced with a
string. You can check that with '-E' or '-migrate -source_listing -show all'.

Hope this helps,
Hartmut
    
2112.2PERL is useful tool for these situations...XDELTA::HOFFMANSteve, OpenVMS EngineeringThu Mar 06 1997 10:377
:    Of course, sprintf can concatenate these strings, but the declarations
:    are in 158 .h files, so I look for some thing simpler.
    Do you have any suggestions ?

   Learn PERL.  It's very good at making these sorts of changes.  � :-)

2112.3DECCXL::OUELLETTEThu Mar 06 1997 11:125
The question of which version of the DEC C compiler on what platform
with what command line (-std vs -vaxc could matter) arrises.
The original code looks OK to me...  your try doesn't.

R.
2112.4Error of "\" in makefile.SEGUR::KUOCHThu Mar 06 1997 12:0411
Hartmut, OUELLETTE,

    Thank you for your replies.

    Now it works, there was a confusion of "\" in makefile variable.
  
    I am sorry.

Regards.
Cheu.