views:

269

answers:

3

I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's the best way to get over this?

For legacy code reasons, the MSDN suggestion of replacing typedefs with structs is not practical.

The typedefs in question are (sanitized code):

enum Type{
    TYPE_COUNT,
    TYPE_VALUE
};

typedef MyVector< Container*, CriticalSectionLock > Containers;
typedef MyVector< MyClassType*, CriticalSectionLock >::const_iterator const_iterator_type;
typedef MyVector< stl::pair< string, Type > >::const_iterator const_iterator_def;
typedef MyVector< Container** >::const_iterator const_iterator_container;
typedef MyVector< stl::pair < MyBase*, MyVector< stl::pair< Container**, Containers* > > > >::const_iterator const_iterator;
+2  A: 

Since there does not appear to be a way to increase the compiler's internal limitation on the decorated name length, I bit the bullet and made the change suggested in the MSDN. see: http://msdn.microsoft.com/en-us/library/074af4b6.aspx

I only had to change the first typedef to a struct. This required about 200 other changes in legacy code, which was tedious, but otherwise not difficult. However, I will be spending the next week or so in regression testing to make sure this did not screw something up.

Here is the basic change: (note that I was forced to add some ctors to the struct)

enum Type{
    TYPE_COUNT,
    TYPE_VALUE
 };

 struct Containers 
 {
    MyVector<Container*, CriticalSectionLock > Element;
    Containers(int num, Container* elem):Element(num, elem){}
    Containers(){}
 };
 typedef MyVector< MyClassType*, CriticalSectionLock >::const_iterator  const_iterator_type;
 typedef MyVector< stl::pair< string, Type > >::const_iterator const_iterator_def;
 typedef MyVector< Container** >::const_iterator const_iterator_container;
 typedef MyVector< stl::pair < MyBase*, MyVector< stl::pair< Container**, Containers* > > > >::const_iterator const_iterator;
TX CHL Instructor
A: 
#pragma warning(disable:xxx).

Life's too short man.

Roel
Unfortunately it also failed to link due to this warning. Other than that: agreed.
Joachim Sauer
A: 

@Roel: As I mentioned in the original posting: "The generated LIB file will not properly link to other modules in the project."

IOW, this is more than just a 'warning'. It causes the project NOT TO WORK.

My posted fix is somewhat difficult and tedious to completely implement, but it does work.

TX CHL Instructor