I'm trying to migrate a project from BCB5 to BCB2007. I have a source file
that utilizes some VCL objects in a function prototype (Works fine in BCB5)
but I keep getting the error during compile time of
"[BCC32 Error] misc100.cpp(11): E2147 'TStringGrid' cannot start a parameter
declaration"
The code is:
#include <stdio.h>
#include <mem.h>
#include <string.h>
#include <vcl.h>
int get_file_check_digit(char *filename, int position);
void read_label_captions(TForm *f, char filename[255]);
void write_label_captions(TForm *f, char filename[255]);
void del_array_element(int num, int index, int *array, int init_value);
void sort_int_array(int num, int *array, int *mirror, int ascending);
ERROR HERE-->void sort_string_grid(TStringGrid *t, int startrow);
Any ideas???
Thank you
Marshall
> I keep getting the error during compile time of
>
> "[BCC32 Error] misc100.cpp(11): E2147 'TStringGrid' cannot start a
> parameter declaration"
That error means that TStringGrid has not been defined yet. You do not have
Grids.hpp included in the code, or have not made a forward declaration for
it, before trying to use it in the function declaration.
> #include <vcl.h>
Including vcl.h by itself is not enough to pull in everything the VCL has to
offer. Many times, you still need to include other header files as well.
In this case, you are trying to use types that are defined in Forms.hpp and
Grids.hpp. TForm works fine because vcl0.h always includes Forms.hpp.
However, if you look at what vcl0.h actually does, you will see that
Grids.hpp is included only if INC_VCLEXT_HEADERS is defined.
INC_VCLEXT_HEADERS is defined by vcl4.h. When you include vcl.h in your
code, the compiler automatically substitutes it with either vcl1.h, vcl2.h,
vcl3.h, or vcl4.h, based on the project settings. Each one of those header
files defines a different set of options for vcl0.h to use.
So, what is likely happening is that your BCB 5 project is configured in
such a way that the compiler decides to use vcl4.h, but your BCB 2007
project is configured in such a way that a different VCL header file is used
instead, and thus Grids.hpp is not being included automatically.
It is for reasons like this that you should never rely on the compiler's
internal behavior to do things for you. If you need to use TStringGrid,
then you should explicitally include Grids.hpp in your own code. If vcl.h
includes Grids.hpp on its own, then your inclusion will simply be ignored.
But in both cases, TStringGrid will be a known type for your code to use.
This logic applies to every other data type you ever want to use in any
project. Don't make assumptions about what the compiler may or may not
define automatically.
Gambit
Wow! All good info! I'm new to 2007 BUT not to BCB. I appreciate the
detailed explanation which gives me a good sense of direction. Assuming will
get me every time!
I haven't seen a good reference yet as to what includes are needed for the
different VCL objects??? Is there a good reference under a specific section
that I'm obviously missing???
BTW: I'm not real thrilled about the upgrade (because of these little
oddities, not unique to Borland) but I needed to get current for support
reasons.
Thank you
Marshall
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47dadc3e$1...@newsgroups.borland.com...
> I haven't seen a good reference yet as to what includes
> are needed for the different VCL objects???
That is described in each class's documentation. The "unit" is the header
file to include. If you look at TStringGrid's documentation, you will see
that it is declared in the "Grids" unit, so you would include "Grids.hpp"
(VCL units that are written in Pascal always use ".hpp" as the file
extension in C++).
> BTW: I'm not real thrilled about the upgrade (because of
> these little oddities, not unique to Borland)
This time around, it was more of a bug in your own code than a quirk of BCB.
You simply were not including Grids.hpp in your code when you should have
been all along. BCB 5 managed to hide that detail from you and work around
it, whereas BCB 2007 was able to point it out to you. So the upgrade
actually helped you by pointing out a bug you needed to fix.
Gambit
Dang! I was hoping I could blame something other than me :-)
Again, I appreciate the help!
Thank you
Marshall
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47dae8eb$1...@newsgroups.borland.com...