Hi
We are using a code generator for initializing structures with the #define macro. Compiling it with the GCC 2.8.1 (with -ansi) it OK. But when we are using the SUN C 5.0 compiler it screams.
Originally posted by amatsaka Compiling it with the GCC 2.8.1 (with -ansi) it OK. But when we are using the SUN C 5.0 compiler it screams.
Does anybody knows why that happens since SUN C5.0 is ANSI/ISO compliant ?
Thanx
From the gcc man page...
Quote:
The -ansi option does not cause non-ISO programs to be rejected gratuitously. For that, -pedantic is required in addition to -ansi.
Try "gcc -ansi -pedantic".
I have tried your code on gcc without either -ansi or -pendantic. I can't get it to compile with any compiler no matter what I do. We do have an older version of gcc, "gcc --version" says 2.95.3. But visually inspecting the code, I'm not surprised that it doesn't compile. Did the code get garbled as you included it the post?
OK,
we used the -pedantic and the gcc (ver 2.8.1) complained at line
T = TEST_NS_C; with the following errors
test.c: In function `main':
test.c:33: warning: ANSI C forbids constructor expressions
test.c:33: warning: ANSI C forbids constructor expressions
test.c:33: warning: ANSI C forbids constructor expressions
So from what -ansi option it's not a safe way anymore.
The error we get in Sun C5.0 compiler is in the same line and it reads
test.c line 33: syntax error before or at: {
which I beleve is for the same reason.
And here is the million dollar question.
How can we initialize complex structures like in the example?
Our application has to send large amount of different messages through TCP or UPD interfaces and we have prepared a code generator that would intialize all the message values to NO_STATEMENT (what ever that means).
I think that I now mostly understand the code that you posted. You're right about gcc. I suggest that you do most of your testing with a C compiler. There is a lot of code out there that happily states "gcc required", a situation simliar to those "IE required" web pages.
You are doing a lot of "typedef struct X { } X". That makes X both a typedef and name of a stucture. Unless you have a very good reason for that, just use "typedef struct { } X".
When you do "#define X_NS_C (X) {...}", what function is the (X) supposed to serve? That is the one part that I can't figure out. I finally just assumed it was a comment and dropped it.
You need a \n in your printf. I never could get my version of gcc to compile your program. When you run your program after a gcc compile, do you get a trailing \n somehow?
The exit(1) is interesting, but I couldn't resist the urge to switch it to exit(0).
Of course, in real life, I would lose those #defines and just go with:
TEST T = { 1, { 2, { 6, 8 } } };
but I guess that you need those defines for some reason. Do you really need to split them to several lines? Even machine generated C code should be readable.
I have tried my code on several c compilers. HP's c++ compiler issued a warning because main() is not typed, but the resulting program ran fine. Other than that, it compiled fine everywhere, including with gcc.
You lost me with that NO_STATEMENT stuff...I hope that wasn't too important.
Hi ,
I was invoking a sh file using the nohup command. But while invoking, I received a below error.
Error occurred during initialization of VM
Unable to load native library: /u01/libjava.so: cannot open shared object file: No such file or directory
.
Could you please help out.
Regards,... (2 Replies)
Hallo Team,
I have a simple request and i would appreciate your help.
I would like to use two dates in my script lets:
A=$(date +"%d %B %Y")
echo $A
23 June 2014
That's awesome now we cooking. Now i want B to be on the previous month
eg: echo $B Should give me
23 May 2014
I would... (9 Replies)
Hi everybody,
my problem is the following:
I'm trying to run an openmpi program on a cluster (atlasz.elte.hu, it's in hungarian, but you can try google translate),
but I always got this error:
Fatal error in MPI_Init: Other MPI error, error stack:
MPIR_Init_thread(394)...........:... (0 Replies)
new to shell scripting.
below line is showing error in script.
${parameter:=word}
in the o/p first it shows the below error.
word: not found.
and then in next line print "word"
----------------
p2: word: not found.
word
---------------------------
OS is AIX and shell is... (12 Replies)
I get an error in my shell script that line 1: )unexpected.
Line 1 in my script (using sh by the way) is the variable I declared but did not initialize it.
result=
Is this wrong? How can I fix it? I am using the variable later in the program, so I figured I could just declare it first... (4 Replies)
Hi,
I have received an application that stores some properties in a file. The existing struct looks like this:
struct TData
{
UINT uSizeIncludingStrings;
// copy of Telnet data struct
UINT uSize;
// basic properties:
TCHAR szHost; //defined in Sshconfig
UINT iPortNr;
TCHAR... (2 Replies)
Can someone tell me how to do this?
Just a thought that entered my mind when learning about structs.
First thought was:
struct one
{
struct two;
}
struct two
{
three;
}
one->two->three
would this be how you would access "three"? (1 Reply)
Hi All,
char a="\0";
a) a contains \0
a contains garbage value
b) a contains \
a contains 0
a contains garbage value
Pls, let me know correct result is a or b. I guess a.
Thanks,
Naga:cool: (2 Replies)
As you know, when a user logs in, the shell reads the initialization files in an order something like below...
###################
Bourne Shell
/etc/profile > $HOME/.profile
Bash Shell
/etc/profile > $HOME/.bash_profile > $HOME/.bash_login > $HOME/.profile > $HOME/.bashrc
C Shell... (3 Replies)