× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Wondering if anyone would be able give a simple source example of an
external data structure definition in OPM C and ILE C ... if the concept
even exists.

Two ways that I know of #pragma mapinc and GENCSRC

They basically do the same thing, except that the #pragma is a preprocessor directive and therefore is run automatically when you invoke the compiler (making it more like RPG's version of this) and GENCSRC is a CL command that you run manually from the command line.

What these options do (both of them) is generate a source member that contains the external definition of the file. In both cases, you have to #include that source member in order to use the data structure definition in your C program.

For example, if you put the following in your C source:

#pragma mapinc ("includeme","mylib/myfile(myrecfmt)","input","")
#include "includeme"

It will generate a (temporary) source member called "includeme" on the fly that contains the data structure definition. It will generate it using the record format called myrecfmt from the file mylib/myfile. It includes input fields (i.e. fields that are not output only, like specifying *INPUT in RPG)

The next line includes that source member so that I can use it in my program. The name of the structure definition will be MYLIB_MYFILE_MYRECFMT_i_t (the "i" stands for input). So I can use that structure definition like that:

int main(int argc, char **argv) {

  MYLIB_MYFILE_MYRECFMT_i_t rec;

  memset(&rec.field1, ' ', 10);

  .
  .
}

That's probably not a great example, but hopefully you get the idea.

The only difference when using GENCSRC is that it's a CL command that you run yourself (or put in a Makefile or whatever) that generates the source member. You use that instead of the #pragma.

That way, you can see the source member that it generates, and keep it around, etc. You still #include it the same way, and use it the same way in your programs.


We're looking for examples in a C program that will cause a file or
external data structure to NOT be picked up by a DSPPGMREF.

I don't think those options will cause anything to be picked up by DSPPGMREF, since all they do is generate source members. The compiler doesn't really know that the source came from a file -- it's just a data structure definition. But, I haven't tested this. Give it a try and see what happens...


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.