c++ template issues

cyclone3d

[H]F Junkie
Joined
Aug 16, 2004
Messages
16,295
VS2010 is giving me syntax errors on a new template I just made.

I am not sure why as the syntax is done the same way as my working template.

On the first line where I am populating the array it says:
Code:
error C2143: syntax error : missing ')' before '<'
error C2143: syntax error : missing ';' before '<'

Working:
Code:
template<class type> struct MultiplicandSelector
{
static void (* const set_multiplicand[10])(type &mpcd, my_uint32 &ldigit, my_uint32 &ldig2, type starting_number);
};

template<class type>
void (* const MultiplicandSelector<type>::set_multiplicand[10])(type &mpcd, my_uint32 &ldigit, my_uint32 &ldig2, type starting_number) = {
zero<type>,one<type>,two<type>,three<type>,four<type>,five<type>,six<type>,seven<type>,eight<type>,nine<type>};

Non-working:
Code:
template<class type> struct OutputSelector
{
static void (* const output_array[256])(my_uint32 array_val, type number, ostream *output);
};

template<class type>
void (* const OuputSelector<type>::output_array[256])(my_uint32 array_val, type number, ostream *output)={
val000<type>,val001<type>,val002<type>,val003<type>,val004<type>,val005<type>,val006<type>,val007<type>,val008<type>,
val009<type>,val010<type>,val011<type>,val012<type>,val013<type>,val014<type>,val015<type>,val016<type>,val017<type>,
val018<type>,val019<type>,val020<type>,val021<type>,val022<type>,val023<type>,val024<type>,val025<type>,val026<type>,
val027<type>,val028<type>,val029<type>,val030<type>,val031<type>,val032<type>,val033<type>,val034<type>,val035<type>,
val036<type>,val037<type>,val038<type>,val039<type>,val040<type>,val041<type>,val042<type>,val043<type>,val044<type>,
val045<type>,val046<type>,val047<type>,val048<type>,val049<type>,val050<type>,val051<type>,val052<type>,val053<type>,
val054<type>,val055<type>,val056<type>,val057<type>,val058<type>,val059<type>,val060<type>,val061<type>,val062<type>,
val063<type>,val064<type>,val065<type>,val066<type>,val067<type>,val068<type>,val069<type>,val070<type>,val071<type>,
val072<type>,val073<type>,val074<type>,val075<type>,val076<type>,val077<type>,val078<type>,val079<type>,val080<type>,
val081<type>,val082<type>,val083<type>,val084<type>,val085<type>,val086<type>,val087<type>,val088<type>,val089<type>,
val090<type>,val091<type>,val092<type>,val093<type>,val094<type>,val095<type>,val096<type>,val097<type>,val098<type>,
val099<type>,val100<type>,val101<type>,val102<type>,val103<type>,val104<type>,val105<type>,val106<type>,val107<type>,
val108<type>,val109<type>,val110<type>,val111<type>,val112<type>,val113<type>,val114<type>,val115<type>,val116<type>,
val117<type>,val118<type>,val119<type>,val120<type>,val121<type>,val122<type>,val123<type>,val124<type>,val125<type>,
val126<type>,val127<type>,val128<type>,val129<type>,val130<type>,val131<type>,val132<type>,val133<type>,val134<type>,
val135<type>,val136<type>,val137<type>,val138<type>,val139<type>,val140<type>,val141<type>,val142<type>,val143<type>,
val144<type>,val145<type>,val146<type>,val147<type>,val148<type>,val149<type>,val150<type>,val151<type>,val152<type>,
val153<type>,val154<type>,val155<type>,val156<type>,val157<type>,val158<type>,val159<type>,val160<type>,val161<type>,
val162<type>,val163<type>,val164<type>,val165<type>,val166<type>,val167<type>,val168<type>,val169<type>,val170<type>,
val171<type>,val172<type>,val173<type>,val174<type>,val175<type>,val176<type>,val177<type>,val178<type>,val179<type>,
val180<type>,val181<type>,val182<type>,val183<type>,val184<type>,val185<type>,val186<type>,val187<type>,val188<type>,
val189<type>,val190<type>,val191<type>,val192<type>,val193<type>,val194<type>,val195<type>,val196<type>,val197<type>,
val198<type>,val199<type>,val200<type>,val201<type>,val202<type>,val203<type>,val204<type>,val205<type>,val206<type>,
val207<type>,val208<type>,val209<type>,val210<type>,val211<type>,val212<type>,val213<type>,val214<type>,val215<type>,
val216<type>,val217<type>,val218<type>,val219<type>,val220<type>,val221<type>,val222<type>,val223<type>,val224<type>,
val225<type>,val226<type>,val227<type>,val228<type>,val229<type>,val230<type>,val231<type>,val232<type>,val233<type>,
val234<type>,val235<type>,val236<type>,val237<type>,val238<type>,val239<type>,val240<type>,val241<type>,val242<type>,
val243<type>,val244<type>,val245<type>,val246<type>,val247<type>,val248<type>,val249<type>,val250<type>,val251<type>,
val252<type>,val253<type>,val254<type>,val255<type>};
 
Code:
void (* const [b]OuputSelector[/b]
There's your problem.

Fixed that before I saw your reply.

At least now it is not giving me the same error.. now when I try to compile, the compiler crashes and gives me this error:

fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.

So I have basically stumped Microsoft's compiler.
 
Got it working.. had a couple more syntax errors and I was passing a couple things incorrectly.

Guess that can kinda be expected when adding about 3500 lines of code all at once before recompiling. :p

I just wish the compiler would point you in the right direction when using templates. As it is, it usually just freaks out and doesn't know what to tell you.
 
You think that's bad, you should try compiling template code in gcc. Enough to give you nightmares.
 
I agree that human parsing of the template errors is difficult, but it's telling you exactly what the problems are. What do you mean that it "freaks out and doesn't know what to tell you?" It's telling you the exact errors it is encountering.
 
I agree that human parsing of the template errors is difficult, but it's telling you exactly what the problems are. What do you mean that it "freaks out and doesn't know what to tell you?" It's telling you the exact errors it is encountering.

When it does this:

fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'msc1.cpp', line 1420)
1> To work around this problem, try simplifying or changing the program near the locations listed above.

When it tells you to try simplifying or changing the program so it will compile, it doesn't give me a good feeling about the error reporting.
 
Back
Top