Hello Everyone,
I am having trouble compiling the MT file to the R file. Below is the message from the BMAKE
The line number 40 in the .H file is "LinkageHeader lnkHdr"
[== Building C:\...\<appname>Linktyp.r, (C:\...\<appname>Linktyp.mt) ==]rsctype @C:\...\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.optMicroStation Type Resource File Generator 03.17.02C:\...\<appname>Attr.h(40) : error: bad struct/union definition: expected typeC:\...\<appname>Attr.h(40) : error: expected ,, got linkHdrBMAKE: call trace line: 84, C:\...\<appname>.mkeMon Apr 22 15:26:07 2019, elapsed time: 0:02
typedef struct userDataHeader { LinkageHeader linkHdr; DSIDataHeader dsiHdr; } UserDataHeader;
What Include file or update do I need to make so that the MT file can be compiled to .r file
Thanks
Peter
Peter Howe said:What Include file or update do I need to make so that the MT file can be compiled to .r file
Ask yourself the reason for the .mt file. It contains very little except some #includes and the publishStructures directive. It's job is to convert a C struct to a binary type interpretation stored in a .rsc file. The type interpretation data is used by the Dialog Manager when passing information between your app. variables and your dialog items. When the Dialog Manager sees "MyStruct.myVariable" in a dialog item access string it can figure out what type of data is in use and how to transfer data between that dialog item and your app. variable.
.mt
#include
publishStructures
.rsc
"MyStruct.myVariable"
The #includes are straightforward: the circuit example .mt has this...
#include <RmgrTools/Tools/datadef.r.h> #include "circuitcomp.h"
The first includes common Bentley definitions and the second includes the circuit app's own struct definitions...
typedef struct batteryinfo { ... }BatteryInfo; typedef struct wireinfo { ... }WireInfo; typedef struct lightinfo { ... }LightInfo; typedef struct circuitinfo {... } CircuitInfo;
The type resource compiler has all the information it needs to convert those struct definitions in the header file to type resource definitions. Other files, such as C++ implementation modules, can use those same structure definitions.
Create a UserDataHeader.r.h file. Write the struct definition in that file. #include only those headers required to make it a valid definition. Include UserDataHeader.r.h in your .mt file. Include UserDataHeader.r.h in the C++ files that need it.
UserDataHeader.r.h
Regards, Jon Summers LA Solutions
Thank you for taking the time to look at my issue. I created a .H file to add the structures which are not being located. When the .R file is compiled there is an error:
{DTYPE_ENDSTRUCT, 1, , DTYPE_LONG},
TestIssue.r(23) : error: expected expression.
I tried to create a test case:
TestIssue.mke
#-------------------------------------------------------------------------------------- # $Source: $ # # $Copyright: $ #-------------------------------------------------------------------------------------- #--------------------------------------------- # Define macros specific to this example #--------------------------------------------- PolicyFile = $(MDLMKI)MicroStationPolicy.mki appName = TestIssue baseDir = $(_MakeFilePath) MDLMKI = $(MSMDE)mki/ MDLINC = ${MSMDE}include/ %include $(MDLMKI)mdl.mki #rCompOpts + -i$(MDLINC) cIncs + -I$(MDLINC) mdlLibs = $(MSMDE)library/ #------------------------------------------------------------------------ # Create & compile the app's type resource using rsctype & rcomp #------------------------------------------------------------------------ $(baseDir)$(appName).r : $(baseDir)$(appName).mt $(baseDir)$(appName).rsc : $(baseDir)$(appName).r
TestIssue.mt
#include <RmgrTools\Tools\datadef.r.h> #include "TestIssue.h" /* */ #pragma packedLittleEndianData createDataDef(ncitemlinkdata, DSI_NCITEM_LINKAGE);
TestIssue.h
#include <RmgrTools\Tools\datadef.r.h> #include "Ustn_structures.h" #if !defined (resource) #define DSI_NCITEM_LINKAGE 20 typedef struct dsiheaderdata { UChar appType; // application element Type (max 256) UChar subType; // application sub class (max 256) UShort elVersion; // element version changes ONLY if/when this } DSIDataHeader; // appType and subType's Data sturcture changes typedef struct userDataHeader { LinkageHeader linkHdr; DSIDataHeader dsiHdr; } UserDataHeader; typedef struct ncitemdata { #if defined (dsiRsc) short buff[12]; // 24 total bytes for largest union member #else union { struct { int isManualOrigin; int originPanelType; } origin; char panelId[8]; char dscrStr[21]; char buff[24]; } u; #endif } NCItemData; typedef struct ncitemlinkdata { UserDataHeader userHdr; NCItemData ncData; } NCItemLinkData; #endif
Ustn_Structures.h
/*----------------------------------------------------------------------+ | | | Linkage Header - Same for all element user data | | | | Use LinkageUtil::GetWords/setWords to get/set linkage size. | | | +----------------------------------------------------------------------*/ struct LinkageHeader { UInt16 wdMantissa:8; // mantissa words: wtf if wdExponent=0 UInt16 wdExponent:4; // exponent for words multiplier UInt16 user:1; // boolean: user data linkage UInt16 modified:1; // boolean: user linkage modified UInt16 remote:1; // boolean: remote linkage UInt16 info:1; // boolean: informational linkage UInt16 primaryID; // User ID number };
The test case creates a.R file and then tries to compile to a .RSC and there is an error because a field is empty.
Any suggestions?
Hi Peter,
Peter Howe said:The test case creates a.R file and then tries to compile to a .RSC and there is an error because a field is empty.
Why you do not share also the created .r file?
I do not assume the problem is in this file, but when you say the error is reported when .r file is compiled and you do not share the file itself, it makes the discussion sources incomplete.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Sorry for not including the file.
#include <Mstn\MicroStation.r.h> #include <RmgrTools\Tools\datadef.r.h> #include <RmgrTools\Tools\cexprrsc.r.h> #pragma pushDataProps #pragma packedLittleEndianData DataDefBlock 20 = /* struct ncitemlinkdata */ { {DTYPE_STRUCT, 4, 0, DTYPE_LONG}, {DTYPE_STRUCT, 2, 0, DTYPE_SHORT}, {DTYPE_STRUCT, 2, 0, DTYPE_SHORT}, {DTYPE_SHORT, 1, ATTR_S_LE, FIRSTMEM | S_ALIGN(DTYPE_SHORT) }, /* */ {DTYPE_SHORT, 1, ATTR_S_LE, 0}, /* primaryID */ {DTYPE_ENDSTRUCT, 1, DTYPE_SHORT, DTYPE_SHORT}, {DTYPE_STRUCT, 2, 0, DTYPE_SHORT}, {DTYPE_CHAR, 1, 0, FIRSTMEM | S_ALIGN(DTYPE_SHORT) }, /* appType */ {DTYPE_CHAR, 1, 0, 0}, /* subType */ {DTYPE_SHORT, 1, ATTR_S_LE, 0}, /* elVersion */ {DTYPE_ENDSTRUCT, 1, DTYPE_CHAR, DTYPE_SHORT}, {DTYPE_ENDSTRUCT, 1, DTYPE_SHORT, DTYPE_SHORT}, {DTYPE_STRUCT, 4, 0, DTYPE_LONG}, {DTYPE_ENDSTRUCT, 1, , DTYPE_LONG}, {DTYPE_ENDSTRUCT, 1, DTYPE_SHORT, DTYPE_LONG} }; DataSize 20 = { 32 }; #pragma popDataProps
The error is on line 23.
Is Line #23 possibly missing a 2nd DTYPE_LONG where the empty comma is?
Bob
Hello Robert Hook
Yes that is what I think is missing. But that file should be generated, so the structure must have something missing?
What change is required?
Hi Peter just a guess,
I have some idea in the deep backside of my brain, there was trouble "UShort" and mt-files Nothing concrete
Maby you could try to replace UShort by some other writing of "unsigned short"
As I say, just some feeling ^_^
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
Hello Volker,
Inspired by your suggestion I tried some different configuration.
The issue seems to be:
union { } u;
Any other suggestions?
Hello Robert Hook, Volker Hüfner,
I am working on 2 other items which are still giving me trouble:
I believe that the move to upgrade to Ustn Connect will require a change for these items but I am not finding it. Any suggestions?
It woud be best : "new question => new task". It helps other to find help later.
MdlFunctionP was a kind of "general key" to quiten the compiler since - I guess - V5 or so. It is mostley replaced bei fitting function pointer You have to look at the help-file for each case.
StringList did not change that much, except it works now with wchar_t. Also have a look at the help-file.