Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C on UNIX Question

C on UNIX Question

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlinuxbeta-testingcode-review
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yadrif
    wrote on last edited by
    #1

    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:

    T L 2 Replies Last reply
    0
    • Y Yadrif

      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:

      T Offline
      T Offline
      tom1443
      wrote on last edited by
      #2

      It is an old Kernighan and Ritchie (K & R) style function equivalent to long TAPEINFO(WORD nparm, BYTE **parmptr, FINFO *parmdec) { ......... }

      Y 1 Reply Last reply
      0
      • Y Yadrif

        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:

        L Offline
        L Offline
        Link2006
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T tom1443

          It is an old Kernighan and Ritchie (K & R) style function equivalent to long TAPEINFO(WORD nparm, BYTE **parmptr, FINFO *parmdec) { ......... }

          Y Offline
          Y Offline
          Yadrif
          wrote on last edited by
          #4

          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.

          Z T 2 Replies Last reply
          0
          • Y Yadrif

            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.

            Z Offline
            Z Offline
            Zac Howland
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • Y Yadrif

              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.

              T Offline
              T Offline
              tom1443
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups