Hi there,
I am trying to compile a C program that I am working on into C++...
the compiler version I am using is:
Code:
gcc version 3.4.1 (Mandrakelinux 10.1 3.4.1-4mdk)
The compiler options I am using are:
Code:
CFLAGS = -p -pg -g -O3 \
-Blib \
-Iinclude -I/usr/local/dislin \
-funroll-loops -finline-functions \
-Wall -W -Werror -Wno-unused
The code in question begins:
Code:
1 #ifndef 631G_H
2 #define 631G_H
3
4 #define GTO_CORE CS1_6[Z][0]*exp(-E1_6[Z][0]*dprod)\
5 +CS1_6[Z][1]*exp(-E1_6[Z][1]*dprod)\
6 +CS1_6[Z][2]*exp(-E1_6[Z][2]*dprod)\
7 +CS1_6[Z][3]*exp(-E1_6[Z][3]*dprod)\
8 +CS1_6[Z][4]*exp(-E1_6[Z][4]*dprod)\
9 +CS1_6[Z][5]*exp(-E1_6[Z][5]*dprod)
10
11 #define D2_GTO_CORE 12.0(E1_6[Z][0]*CS1_6[Z][0]*exp(-E1_6[Z][0]*dprod)\
12 +E1_6[Z][1]*CS1_6[Z][1]*exp(-E1_6[Z][1]*dprod)\
13 +E1_6[Z][2]*CS1_6[Z][2]*exp(-E1_6[Z][2]*dprod)\
14 +E1_6[Z][3]*CS1_6[Z][3]*exp(-E1_6[Z][3]*dprod)\
15 +E1_6[Z][4]*CS1_6[Z][4]*exp(-E1_6[Z][4]*dprod)\
16 +E1_6[Z][5]*CS1_6[Z][5]*exp(-E1_6[Z][5]*dprod))
17
18 #define VALENCE_S CS2_3[Z][0]*exp(-E2_3[Z][0]*dprod)\
19 +CS2_3[Z][1]*exp(-E2_3[Z][1]*dprod)\
20 +CS2_3[Z][2]*exp(-E2_3[Z][2]*dprod)
21
22 #define D2_VALENCE_S CS2_3[Z][0]*exp(-E2_3[Z][0]*dprod)*(-6.0*E2_3[Z][0]+4.0*E2_3[Z][0]*E2_3[Z][0]*dp
23 +CS2_3[Z][1]*exp(-E2_3[Z][1]*dprod)*(-6.0*E2_3[Z][1]+4.0*E2_3[Z][1]*E2_3[Z][1]*dp
24 +CS2_3[Z][2]*exp(-E2_3[Z][2]*dprod)*(-6.0*E2_3[Z][2]+4.0*E2_3[Z][2]*E2_3[Z][2]*dp
25
26 #define VALENCE_XYZ CP2_3[Z][0]*component*exp(-E2_3[Z][0]*dprod)+\
27 CP2_3[Z][1]*component*exp(-E2_3[Z][1]*dprod)+\
28 CP2_3[Z][2]*component*exp(-E2_3[Z][2]*dprod)
29
30 #define D2_VALENCE_XYZ -4.0*((1.5*component+1.0-E2_3[Z][0]*factor)*E2_3[Z][0]*CP2_3[Z][0]*exp(-E2_3[Z][0
31 +(1.5*component+1.0-E2_3[Z][1]*factor)*E2_3[Z][1]*CP2_3[Z][1]*exp(-E2_3[Z][1
32 +(1.5*component+1.0-E2_3[Z][2]*factor)*E2_3[Z][2]*CP2_3[Z][2]*exp(-E2_3[Z][2
33
34 #define EXTRAVAL_S CS2_1[Z]*exp(-E2_1[Z]*dprod)
35 #define D2_EXTRAVAL_S CS2_1[Z]*exp(-E2_1[Z]*dprod)*(-6*E2_1[Z] + 4*E2_1[Z]*E2_1[Z]*dprod)
36 #define EXTRAVAL_XYZ CP2_1[Z]*exp(-E2_1[Z]*dprod)
37 #define D2_EXTRAVAL_XYZ -4.0*(1.5*component+1.0-E2_1[Z]*factor)*(E2_1[Z]*CP2_1[Z]*exp(-E2_1[Z]*dprod))
(some of it got chopped off but that doesn't matter because I think it's something fundamentally un-C++ I am doing (yet which google won't seem to yield its secrets on) rather than something in my definitions themselves).
and the error I am getting is:
Code:
In file included from chi.c:2:
include/631G.h:1:9: macro names must be identifiers
chi.c: In function `double chi(basis_function, evector)':
chi.c:35: error: `EXTRAVAL_S' undeclared (first use this function)
chi.c:35: error: (Each undeclared identifier is reported only once for each function it appears in.)
chi.c:52: error: `VALENCE_S' undeclared (first use this function)
chi.c:56: error: `VALENCE_XYZ' undeclared (first use this function)
chi.c:70: error: `EXTRAVAL_XYZ' undeclared (first use this function)
Can anyone help?
I searched the forums already and no luck (I also searched google) - the closest I came was someone saying that what someone wanted to do wouldn't work because "macros names must be identifiers and ' isn't"
so I'd be very greatful if one of you C++ gurus could help out a total C++ virgin get his C program working as a C++ program so he can benchmark them against each other
james
*edit*
Bloody hell!!!!
I am glad I posted this here because I just saw THIS!:
Code:
#define D2_GTO_CORE 12.0(E1_6[Z][0]*
I left out the multiplication symbol after the 12.0...
this I guess is one of the real and horrible dangers of macros.
does anyone know how this might be interpreted by the C compiler??
why didn't it complain?
*edit*
ARGH!!!!
I just tried compiling with the C compiler (I renamed the C++ makefile I was using and replaced it with the original) AND I GOT THE SAME ERRORS!?
*edit
(never mind - a make clean fixed that )
*edit
well for some reason that fixed it and it compiled each of the object files.
HOWEVER, now I just have 1056 lines of various other errors to deal with.
joy joy joy