-1

I am trying to define a dynamic array in Embarcadero C++Builder 10.2 Tokyo. I have tried to use a lot of different syntaxes, but I always get an error.

My latest idea is copied from an Embarcadero example. I copied this example from the help:

typedef DynamicArray< DynamicArray < AnsiString > > T2DStringArray;

And tried to compile it, but I receive this error:

[bcc32 Error] Comm.cpp(10): E2257 error, expected at first '<' sign...

How can I define a dynamic array type, when the help description and example is wrong? Where am I making a mistake?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
P.Ferenc
  • 1
  • 4
  • did you try to compile it in empty app? If it compiles then the problem is else where if not then you got problem with compiler (bug or overwritten lib file). Also if `SCIO_Comm.cpp` line 10 is not the place where your `T2DStringArray` is defined it could hint something ... – Spektre Jun 14 '17 at 09:09
  • Yes, of course I tried it. When I commented out this line the 'empty' code compiled - and running - fine... – P.Ferenc Jun 14 '17 at 12:38
  • You misunderstood ... by emty app I mean: creating new empty App (single VCL form no components or events or code in it) and add that line for example into Main form constructor. If it compiles or not ... – Spektre Jun 14 '17 at 15:15
  • Ok, I tried it and the situation... When I create a fresh new application and add "typedef DynamicArray< DynamicArray < AnsiString > > T2DStringArray;" to main form then everything is fine till... ...When I add a new unit to previously worked (sucessfull compiled) project, and add this line to unit2 then got an error message... – P.Ferenc Jun 14 '17 at 17:13
  • hmm that is strange indeed... despite of what some users here wrote my experience is that files added to project (like units or forms) are compiled differently then `#included` files I would try to make an `*.h` file handled by `#ifndef xxx \r\n #define xxx \r\n typedef ... ; #endif` and do all typedefs there ... then include it (not add to project) where you need to ... That usually solves problems like this but I am used to older compilers like BCB5 and BDS2006 so in your case it could be something else entirely. – Spektre Jun 14 '17 at 21:10
  • @Spektre: Please provide a [mcve] demonstrating the error in action. Nothing you have described makes sense, which means you have to be doing something wrong. – Remy Lebeau Jun 14 '17 at 22:03
  • compare the compiler invocation string from the old and new units... see if any switches differ – M.M Jun 14 '17 at 23:59
  • @RemyLebeau I can't as I stop using add to project for non form units years ago and all problems stop there. But as I mention to you in some comment before that was in BCB5,6 time and I do not know if is relevant for newer IDEs. In the time I was teaching I sow it many times when students was doing simple programs in BCB6 using non form units added to project instead of simple `#include` in main form code. After program grows to some point suddenly compiler starts throwing any compile time errors which was not there... swapping lines of code or adding empty line usually helps up to a point. – Spektre Jun 15 '17 at 05:13
  • @RemyLebeau but yes I could have some bad practice in my coding which can generate such problems. Anyway at that time if my code was around 0.5MByte long it was 75% of the time uncompilable (BCB5) if I used just `#include` I got no problems even with 5MByte of pure code (for some huge CAD/CAM systems). Anyway The OP description of the problem is very similar to this old issue so it is a worth try I think .... – Spektre Jun 15 '17 at 05:18
  • @Spektre: you are definitely doing something wrong. I use BCB6 every day for work, making large (25+ MB) apps with dozens of non-form units and millions of lines of code in them, and "Add to Project" works just fine. I even use `DynamicArray` at times (though `std::vector` is preferred for pure C++ code that doesn't interact with Delphi code). – Remy Lebeau Jun 15 '17 at 06:07
  • @RemyLebeau there is a slight possibility Borland fixed that issue with some update I did not have at that time. – Spektre Jun 15 '17 at 06:28
  • @RemyLebeau just in case take a look at this [Improving performance of click detection on a staggered column isometric grid](https://stackoverflow.com/a/35917976/2521214) and search `#ifndef _isometric_h` to see my style of coding maybe you spot something I am doing wrong there (it is example of `*.h` file I `#include`) and next code chunk is the VCL form code that uses it (and yes I know the `iso` should be in header instead but then I would need to copy also it to that answer and I was nearing 30KB limit). PS at time of problem I was not using macro chunks of code – Spektre Jun 15 '17 at 06:55

1 Answers1

0

Finally I found a solution way at Embacadero site: sysdyn.h But it's not possible to include directly...

Have to use a System.hpp

P.Ferenc
  • 1
  • 4