Strange non-standard C syntax?

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

Reply to
John Speth
Loading thread data ...

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
Reply to
Simon Clubley

"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

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
Reply to
John Speth

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

Reply to
Tauno Voipio

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
Reply to
Simon Clubley

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

Reply to
Stefan Reuther

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.

Reply to
Hans-Bernhard Bröker

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

Reply to
George Neuner

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.