Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile ancient `.c` file with % mark?

Tags:

c

I found some really old codes in my company's code base, some of them probabily can be traced back to 30 yrs ago. Within those files, I found some strange .c files, they looks extremely like pure C codes, except for some macros (?) start with percentage mark, for example,

%IF ( .NOT. WIN32 ) THEN
%INCLUDE (header)
%ENDIF

int func(blablabla...)
....

I believe this syntax comes from Fortran, but every other statements are in legal pure C, even the comments start with /** and //. So I wonder what's this C dialect, and how can I compile it nowadays?

like image 687
Nekomiya Kasane Avatar asked Sep 15 '25 12:09

Nekomiya Kasane


1 Answers

Looks like a proprietary preprocessor. It has little to do with being old code, the C preprocessor has never accepted such. It is not possible perhaps to determine the purpose of this preprocessor since what it appears to be used for in this short example is entirely possible in the standard preprocessor.

To build the code you might simply replace all such preprocessor directives with standard ones. But you may have to make some assumptions about the semantics. For example:

#if !defined WIN32
#include "header"
#endif

int func(blablabla...)
...
like image 84
Clifford Avatar answered Sep 17 '25 05:09

Clifford