1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Strange non-standard C syntax?

Discussion in 'Embedded' started by John Speth, Jul 31, 2012.

  1. John Speth

    John Speth Guest

    HI folks-

    I'm in the middle of porting a C source code package that has two
    non-standard C constructs.

    The first is:

    if ( isr_dsc->id in[VALID_RANGE] )
    {
    /* CONFIGURE INTERUPT */
    rc = OAL_SUCCESS;
    }

    That comes from an interrupt handler install function.

    The second is:

    #define PSP_ [PROC] _[BOARD] _[RTOS] _[COMPILER]

    That comes from a library build configuration header file.

    Maybe I can craft some alternative code if I could look up what the design
    intent is. I will have no access to the code author for a few days (maybe
    never). Has anyone ever seen these kinds of things and know what C compiler
    might accept them?

    Thanks - JJS
     
    John Speth, Jul 31, 2012
    #1
    1. Advertisements

  2. Are you sure the code is not run through some kind of external
    pre-processor before compilation ?

    IOW, how do you know that this file, as it exists, is intended to be
    used directly by a C compiler ?

    If it is intended to be used directly, (ie: you find a reference in a
    Makefile for example), then there's got to be some C preprocessor
    level rewriting going on.

    Simon.
     
    Simon Clubley, Jul 31, 2012
    #2
    1. Advertisements

  3. John Speth

    John Speth Guest

    "Are you sure the code is not run through some kind of external
    pre-processor before compilation ?"

    The package was zipped with no makefile and included a note that no makefile
    is necessary. The note also said it should be built with any C99 compiler.
    I figured that some non-standard compiler was used for testing the code.

    JJS

    "Simon Clubley" wrote in message
    Are you sure the code is not run through some kind of external
    pre-processor before compilation ?

    IOW, how do you know that this file, as it exists, is intended to be
    used directly by a C compiler ?

    If it is intended to be used directly, (ie: you find a reference in a
    Makefile for example), then there's got to be some C preprocessor
    level rewriting going on.

    Simon.
     
    John Speth, Jul 31, 2012
    #3
  4. John Speth

    Tauno Voipio Guest

    Check the headers included with the modules in question,
    also the indirectly included (by already included headers).

    The brackets are suspect - like input to some configuration
    program before compilation.

    --

    Tauno Voipio
     
    Tauno Voipio, Jul 31, 2012
    #4
  5. What was the original build/development environment ?

    I find the makefile comment strange. Are you expected to issue build commands
    manually or did the original author mean there's a alternate build mechanism ?

    I am assuming you have done a grep on the full source tree (not just *.c and
    *.h files) for these placeholder names and have not found any matching
    configuration parameter files (to be used with a external tool) or scripts
    to perform substitution on a copy of the source.

    It's possible the original author was using some IDE setup which substituted
    these placeholders when a compile was issued and then built the modified
    version of the code. I'm not a IDE person (emacs plus a well equipped CLI
    is my preferred development environment) so I don't know if this is
    standard with some IDEs.

    It would explain however why they might think the code is complete in it's
    current state and why build scripts don't appear to be in the source tree
    itself.

    Did you have any luck searching for C preprocessor directives ?

    Simon.
     
    Simon Clubley, Jul 31, 2012
    #5
  6. I occasionally see code like this when cutting&pasting code from PDF
    files. The cut&paste function mistakes some underscores in identifiers
    like "id_in" for underlining and inserts arbitrary word breaks, doubles
    the underscores or otherwise mangles them.

    Is there any chance that the code was created that way?


    Stefan
     
    Stefan Reuther, Aug 5, 2012
    #6
  7. So find out what compiler that code was actually meant for, and look up
    its manual. These days those things are typically available on-line.
     
    Hans-Bernhard Bröker, Aug 5, 2012
    #7
  8. Projects with a single C file often lack a makefile. The OP hasn't
    said much about the actual project ... this particular file may be a
    stand alone library or subsystem rather than a top level project
    itself. However, I agree that the comment re: the makefile seems a
    bit odd.

    George
     
    George Neuner, Aug 5, 2012
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.