views:

92

answers:

2

I have been trying to compile netcat.c on AIX for some time (using the command make aix), but the compiler gives me some weird feedback such as :

"netcat.c", line 117.12: 1506-275 (S) Unexpected text 'int' encountered.

when checked the file netcat.c at line 117, I would find the line (second line in code below):

#ifdef HAVE_BIND
extern int h_errno;
/* stolen almost wholesale from bsd herror.c */

even if I changed the int into char for the same of testing, save the file and re-run the command I get the same error

am I missing something in reading the error code?

+1  A: 

When innocent-looking code produces bizarre errors, try running the code through the C preprocessor stage, and looking at it then. Sometimes macros do very funny things.

Also note that a problem on an earlier line (missing semicolon, etc.) might produce an error message on a later line.

Artelius
aren't preprocessors written with no semicolons? how to run the code with preprocessor stage? any Makefile change required to do so?PS: I am using cc to compile
A.Rashad
@A.Rashad, Artelius doesn't mean the line immediately preceding (which you've shown us anyway). We need _more_ context to be able to figure it out.
paxdiablo
+2  A: 

If you're using xlc (especially older ones), it's normally caused by declarations after statements, something like:

i = i + 1;
int x;

You probably need to give us a little more context, such as 10 or so lines before the error line.

My advice would be to get gcc running on that box if you are using an older xlc. IBM makes some fine compilers now but the earlier ones weren't so crash hot (in my opinion).

paxdiablo
it does have declarations in the middle of the code.should I reconsider defining them in the beginning of each function and try one more time?
A.Rashad
That depends entirely on whether your compiler allows the declarations after statements. I think that was introduced in ISO C99 but don't quote me :-) If your compiler pre-dates that then you will have a problem, hence my suggestion to use an up-to-date xlc or gcc.
paxdiablo