CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2002
    Posts
    10

    How to work around warning C4786

    Hello,

    i'm new to STL and tried to use it's map class:

    map<String, DataNode*> m_map;

    That produces warning C4768 with VC6, SP5, (identifier was truncated to '255' characters in the debug information).

    Is there a way to suppress this warning or another workaround? I do not want to switch warnings off, but information gets lost in more than 200 warnings. Beside compilation becomes pretty slow.

    thanks
    >>Keyboar error. Press F1 to resume<<

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    #pragma warning(disable:4786)

    the warning number is listed in the huge warning, so if your number is different simply replace 4786. Please note that the pragma should go just after the #include "stdafx.h"
    Succinct is verbose for terse

  3. #3
    Join Date
    Sep 2002
    Posts
    10
    Thanks, but disabling warning C4786 via pragma directive is not possible due to a VC6 bug not fixed.... Visual C++ v7 fixes these problems *wink wink*

    But I think I' ve found something interesting, will be back soon
    >>Keyboar error. Press F1 to resume<<

  4. #4
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    It must not be in a #include. It has to be in the source.
    Succinct is verbose for terse

  5. #5
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Uhh *wink* *wink* I use VC6.0 SP5 and

    #pragma warning(disable:4786)

    all the time. And *wink* *wink* it works.

  6. #6
    Join Date
    Sep 2002
    Posts
    10
    I' ve put the pragma in all affected cpp's and it works well *wink* *wink* ;-)

    Thank You Very Much, Bye
    Last edited by PBateman; September 25th, 2002 at 03:50 PM.
    >>Keyboar error. Press F1 to resume<<

  7. #7
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Well cup, I use mine in the header and it works for me. My cpp file for that header does use std::wstring which also will generate the warning and has no pragma defined. But whatever he got his issue solved

  8. #8
    Join Date
    Sep 2002
    Posts
    10
    It also works fine putting it in front of all other includes in stdafx.h.

    Good night...
    >>Keyboar error. Press F1 to resume<<

  9. #9
    Join Date
    May 2002
    Location
    Quebec City, Canada
    Posts
    374
    In a big project we have at work, we're getting this warning even when using the #pragma keyword in every place imaginable. We've kind of given up on these. We're using VC++6. What a ****!

    Edit: **** == a place where belzhebut dwelves
    Martin Breton
    3D vision software developer and system integrator.

  10. #10
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    I've found that it doesn't work when I do a full system build but it does work when I'm doing individual builds. Maybe this was the bug that PBateman was talking about.

    Someone once explained why this was happening but I was new to VC++ then and it was way over the top of my head. At that time, I was still trying to figure out what to click on.
    Succinct is verbose for terse

  11. #11
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Well I work on a large project doing full builds, and we still don't get the errors (and trust me before I went in and put the #pragma's when I started at this company it was a build mess!). But there is too many differences between everyones' configuration here. Did you try #pragma in all cpp and .h's. I doesn't hurt It's probably your hitting the definition before your #pragma kicks off.

  12. #12
    Join Date
    May 2002
    Location
    Quebec City, Canada
    Posts
    374
    No, there are just too many files to justify the task of adding the #pragma in everyone of them!

    It is in every .h and .cpp where a STL container is found though, but it seems the compilor is having a hard time when the include file is included in another .h which is included in another .h and so on... it seems the farthest it gets from the #pragma, the most likely the warning reappears.

    Weird.
    Martin Breton
    3D vision software developer and system integrator.

  13. #13
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    *lol* sorry I meant in every file dealing with STL. That's how i have it. It's not probably worth the time for you to try and unwind the headers, unfortunetly I will have to do that myself here, because the headers are just a #include mess 2. I don't look forward to that. Alot of people are just too lackadaisical when it comes to headers file IMHO.

  14. #14
    Join Date
    May 2002
    Location
    Quebec City, Canada
    Posts
    374


    Indeed. #include is a bloody **** when it's not done properly. I hate it when the code comes down to the syndrome:

    change a character in a .h and have to recompile the whole thing

    However, in order not to do that, maybe we all have to go throuhg it... so that we hate it so much we never do the same?
    Martin Breton
    3D vision software developer and system integrator.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured