C on UNIX Question
-
Hello Everyone. I have the following C code snippet: long TAPEINFO(nparm, parmptr, parmdec) WORD nparm; BYTE **parmptr; FINFO *parmdec; { ....Code in the function goes here.... } I'm not an expert by any means in C but I have done a litte C development on Linux and have never seen code like this before. The variables that are defined directly below the function header seem wierd. The problem is a compile error stating "nparm is undefined" and pointing at nparm in the function header line. Is the definition after the function header supossed to define nparm? If someone could provide any feedback I'd appreciate it. Thanks.:confused:
-
Hello Everyone. I have the following C code snippet: long TAPEINFO(nparm, parmptr, parmdec) WORD nparm; BYTE **parmptr; FINFO *parmdec; { ....Code in the function goes here.... } I'm not an expert by any means in C but I have done a litte C development on Linux and have never seen code like this before. The variables that are defined directly below the function header seem wierd. The problem is a compile error stating "nparm is undefined" and pointing at nparm in the function header line. Is the definition after the function header supossed to define nparm? If someone could provide any feedback I'd appreciate it. Thanks.:confused:
-
Hello Everyone. I have the following C code snippet: long TAPEINFO(nparm, parmptr, parmdec) WORD nparm; BYTE **parmptr; FINFO *parmdec; { ....Code in the function goes here.... } I'm not an expert by any means in C but I have done a litte C development on Linux and have never seen code like this before. The variables that are defined directly below the function header seem wierd. The problem is a compile error stating "nparm is undefined" and pointing at nparm in the function header line. Is the definition after the function header supossed to define nparm? If someone could provide any feedback I'd appreciate it. Thanks.:confused:
It's the orginial C syntax before the ANSI C standards. The first edition of The C Programming Language was written in this style. You should be able to get a used copy on Amazon.com. People usually refer it as K&R C.
-
It is an old Kernighan and Ritchie (K & R) style function equivalent to long TAPEINFO(WORD nparm, BYTE **parmptr, FINFO *parmdec) { ......... }
Do you think the compile error could be because the compiler doesn't recognize the syntax? Here is the compiler output: "usrfunct.c", line 91: error #2020: identifier "nparm" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmptr" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmdec" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 92: error #2130: expected a "{" WORD nparm; I've actually been emailed the source and just asked to see if I can figure out why it won't compile. I think it is an HP UNIX box. By looking at the make log it seems like the compiler is called aCC. Once again never seen this but have never worked with C on HP UNIX before. Thanks for your help.
-
Do you think the compile error could be because the compiler doesn't recognize the syntax? Here is the compiler output: "usrfunct.c", line 91: error #2020: identifier "nparm" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmptr" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmdec" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 92: error #2130: expected a "{" WORD nparm; I've actually been emailed the source and just asked to see if I can figure out why it won't compile. I think it is an HP UNIX box. By looking at the make log it seems like the compiler is called aCC. Once again never seen this but have never worked with C on HP UNIX before. Thanks for your help.
What compiler and version are you using? CC is usually an environment variable pointing to whatever C-compiler you want to use. Typically, you will see the makefile (or configure script) have something along the lines of: CC=gcc ... $(CC) $(CFLAGS) usrfunct.c Depending on what compiler you are using, you may have to set a flag to allow it to read old-style syntax (K&R C).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Do you think the compile error could be because the compiler doesn't recognize the syntax? Here is the compiler output: "usrfunct.c", line 91: error #2020: identifier "nparm" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmptr" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 91: error #2020: identifier "parmdec" is undefined long TAPEINFO(nparm, parmptr, parmdec) ^ "usrfunct.c", line 92: error #2130: expected a "{" WORD nparm; I've actually been emailed the source and just asked to see if I can figure out why it won't compile. I think it is an HP UNIX box. By looking at the make log it seems like the compiler is called aCC. Once again never seen this but have never worked with C on HP UNIX before. Thanks for your help.
Sounds like a strong possibility which is easily checked. Three options: 1. Just convert the function over from K&R style parm list to an ANSI style list and give it a try. 2. Do a man on aCC and try and figure out what compiler flag enables K&R. 3. You should be able to do something like is done is this example because I believe all ANSI compilers predefine __STDDC__: #ifdef __STDC__ void psm_update_cfg_srcs(UINT16 srcs, UINT16 installed, UINT16 present, UINT16 enabled) #else void psm_update_cfg_srcs(srcs, installed, present, enabled) UINT16 srcs; UINT16 installed; UINT16 present; UINT16 enabled; #endif