[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Texmacs-dev] Re: TeXmacs port to IRIX
From: |
Philipp Tomsich |
Subject: |
Re: [Texmacs-dev] Re: TeXmacs port to IRIX |
Date: |
Tue, 14 Jan 2003 07:01:38 -0800 |
On Tue, 14 Jan 2003 address@hidden wrote:
> Also, on non-GNU compiler the default debugging options should
> probably be -g instead of -ggdb. What is the option to get the most
> debugging information out of your compiler?
It's "-g3"
> I think then that it may be interesting to factor-out the
> implementation of 'fast_array' to use stack allocation when available.
> I thought of using compile-time dispatch, but that does not help.
> Instead we may use a macro (yuck!).
>
> #if CONFIG_USE_VLA
> #define VARIABLE_LENGTH_ARRAY(TYPE,NAME,NUMBER) TYPE NAME[NUMBER]
> #else
> #define VARIABLE_LENGTH_ARRAY(TYPE,NAME,NUMBER) fast_array<TYPE>
> NAME(NUMBER);
> #endif
>
> template<class T> class fast_array<T> {
> T *a;
> public:
> inline fast_array(int n) { this->a = new T[n]; }
> inline T& operator[] (const int i) { return this->a[i]; }
> inline ~fast_array() { delete[] this->a; }
> };
>
> Used as
>
> VARIABLE_LENGTH_ARRAY(char, data, byte_width * h);
>
> Instead of
>
> char data [byte_width * h];
>
> That way we get all the speed we can, without cluttering the code with
> ifdefs and gotos (YUCK!!!).
I've actually started work on a similar macro just a few minutes ago... I
too wanted to get rid of the gotos. I'll fix something up that uses these (or
similar macros).
> I am unsure that is really a compiler problem, and unsure the fix is
> right. For the record, the original code looks like:
>
> tree** rs= new (tree*)[nr_rows];
> What is the actual error you are getting from your compiler?
cc-1140 CC: ERROR File = ./Edit/Modify/edit_table.cc, Line = 554
A value of type "tree *" cannot be used to initialize an entity of type
"tree **".
tree** cs= new (tree*)[nr_rows];
^
1 error detected in the compilation of "./Edit/Modify/edit_table.cc".
~
> Actually it seems that tree*[nr_rows] effectively means 'array of
> nr_rows pointers to tree'. So the following is correct:
>
> tree** rs= new tree*[nr_rows];
>
> A similar example is given in section 8.1 [dcl.name].
Leaving off the parathesis gives the expected result. Thanks, you're right
about this.
--phil.