Search code examples
c++cscip

SCIP: About the "SCIP_ReaderData" in the bin packing example


A quesion about the reader plugin defined in the binpacking example. I found the following declaration in the interface method (file reader_bpa.c),

 SCIP_READERDATA* readerdata;
 readerdata = NULL;

I know SCIP_READERDATA is defined in file type_reader.h:

typedef struct SCIP_ReaderData SCIP_READERDATA;

However, the struct SCIP_ReaderData is not defined in the binpacking reader, so which is the actual struct that "SCIP_READERDATA* readerdata;" reference to? what kind of pointer is readerdata?

PS: I noticed that the default readers in SCIP have similar usage.


Solution

  • That is more a C-question than a SCIP question if I am not mistaken. The interface functions SCIPincludeReader() and SCIPincludeReaderBasic() require a pointer to reader data as last argument. Reader data is supposed to allow the plugin author to connect arbitrary data with their reader plugin by declaring the corresponding struct SCIP_ReaderData as many other plugins do. If you try to do anything with the pointer, e.g., allocate memory for it using SCIPallocMemory(scip, &readerdata), you will get compiler errors because the pointer refers to an incomplete type, namely struct SCIP_ReaderData.

    More useful information on incomplete types is found, e.g., here

    The point is, the example uses this to make it clearer which arguments are passed to the SCIPIncludeReaderBasic()-function, where you would see NULL otherwise.