Forums

Strange non-standard C syntax?

Started by John Speth July 31, 2012
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

On 2012-07-31, John Speth <johnspeth@yahoo.com> wrote:
> 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? >
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, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world
"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 news:jv94hd$mel$1@dont-email.me...

On 2012-07-31, John Speth <johnspeth@yahoo.com> wrote:
> 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? >
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, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world
On 31.7.12 9:43 , John Speth wrote:
> "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. >
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
> > "Simon Clubley" wrote in message news:jv94hd$mel$1@dont-email.me... > > On 2012-07-31, John Speth <johnspeth@yahoo.com> wrote: >> 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? >> > > 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. >
On 2012-07-31, John Speth <johnspeth@yahoo.com> wrote:
> "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. >
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, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world
John Speth wrote:
> 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; > } > [...] > Has anyone ever seen these kinds of things and know > what C compiler might accept them?
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
On 31.07.2012 18:23, John Speth wrote:

> Maybe I can craft some alternative code if I could look up what the > design intent is.
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.
On Tue, 31 Jul 2012 22:13:44 +0000 (UTC), Simon Clubley
<clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:

>On 2012-07-31, John Speth <johnspeth@yahoo.com> wrote: >> "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. > >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 ?
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