jacob-carlborg / dstep

A tool for converting C and Objective-C headers to D modules
204 stars 37 forks source link

error: must use 'struct' tag to refer to type ... #255

Open Robert-M-Muench opened 4 years ago

Robert-M-Muench commented 4 years ago

I have this code on windows and run dstep on Windows 64-bit too:

#pragma once

#include <cstring>
#include <cassert>

struct som_passport_t;

typedef UINT64 som_atom_t;

struct som_asset_t;

struct som_asset_class_t {
  long(*asset_add_ref)(som_asset_t* thing);
  long(*asset_release)(som_asset_t* thing);
  long(*asset_get_interface)(som_asset_t* thing, const char* name, void** out);
  som_passport_t* (*asset_get_passport)(som_asset_t* thing);
};

For this code snippet I get a bunch of errors:

./include/sciter-om.h:4:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
./include/sciter-om.h:14:24: error: must use 'struct' tag to refer to type 'som_asset_t'
./include/sciter-om.h:15:24: error: must use 'struct' tag to refer to type 'som_asset_t'
./include/sciter-om.h:16:30: error: must use 'struct' tag to refer to type 'som_asset_t'
./include/sciter-om.h:17:3: error: must use 'struct' tag to refer to type 'som_passport_t'
./include/sciter-om.h:17:41: error: must use 'struct' tag to refer to type 'som_asset_t'

I really don't understand the problem, because this is pretty straight forward C code. Any idea how to solve this?

jacob-carlborg commented 4 years ago

Based on the error messages I would say this is a C++ header file. In C, when referring to the name of a struct, the keyword struct need to be included. Currently DStep doesn't support C++. This particular header might still work if you set the language to C++, same flags as for Clang.

Robert-M-Muench commented 4 years ago

Ok, thanks. Trying.

BTW: Is there a way that Dstep will write the result as far as it made it? And not stop on an error? With this I could take the result and manually fix/extend all missing parts.

jacob-carlborg commented 4 years ago

Unfortunately no. If there are compile errors those will occur before DStep get an chance to process.