getting rid of warning C4786 
Author Message
 getting rid of warning C4786

Hello,

Can somebody give me some pointers of how to get rid of those damn C4786
warnings?  I've added a bunch of #pragma warning (disable:4786) but these
things keep showing up.  How can I track down what is causing these warnings
(the warnings have to be the most cryptic things I've ever seen)?  Where
exactly should I be placing my #pragma disables?

Any advice would be greatly appreciated.

Thanks,
Andrew



Sun, 28 Sep 2003 22:45:29 GMT  
 getting rid of warning C4786
Just ran across another post asking the same question... but pls let me know
if anybody else has any other tips.

Thanks



Sun, 28 Sep 2003 23:05:43 GMT  
 getting rid of warning C4786
Actually the other stuff didn't help.  C4786 is less than a level 4 warning,
so the pop/push approach won't work.  I'm still looking for tips then. :)


Quote:
> Just ran across another post asking the same question... but pls let me
know
> if anybody else has any other tips.

> Thanks



Sun, 28 Sep 2003 23:11:13 GMT  
 getting rid of warning C4786

After _I_ added this #pragma, the warning never showed up again :-))

But I just found THIS in the MSKB:

"
BUG: C4786 Warning Is Not Disabled with #pragma Warning

----------------------------------------------------------------------------
----
The information in this article applies to:

Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0

----------------------------------------------------------------------------
----

SYMPTOMS
Warnings similar to the following are generated even if you use the warning
pragma to disable the warning:

warning C4786:
'std::rb_tree<CAiSpanningTree<State,std::less<State>>::TransClosureNode,
CAiSpanningTree<State,std::less<State>>::TransClosureNode,std::ident<Cai
SpanningTree<State,std::less<State>>::TransClosureNode,CAiSpanningTree<S
tate,std::less<State>>::TransClosureNode>,std::less<CAiSpanningTree<Stat
e,std::less<State>>::TransClosureNode>>' : identifier was truncated to '255'
characters in the debug information
The code:

   #pragma warning(disable:4786)
disables warnings that list the file and line number. For example:

   C:\test\Text.cpp(25) : warning C4786:

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at
the beginning of this article.

MORE INFORMATION
This warning can be ignored. However, the identifier may not be accessible
or viewable in the de{*filter*}.

Sample Code

   /*
   Compiler Options: /Zi
   */

   #include <stddef.h>
   #include <new.h>
   #pragma warning(disable:4786)

   namespace std {

      template <class T, class U>  struct ident {};
      template <class T1, class T2> struct pair {};
      template <class Arg1, class Arg2, class Result>
         struct binary_function {};
      template <class T>struct less : binary_function<T, T, bool> {};
      template <class T, class Distance> struct bidirectional_iterator {};
      template <class Key, class Value, class KeyOfValue, class Compare>
        class rb_tree {
          public:
             typedef int size_type;
             typedef int difference_type;
             typedef void* link_type;
             struct rb_tree_node {};
             typedef Key key_type;
             class iterator : public bidirectional_iterator<Value,
                difference_type> {};
             class const_iterator   : public
                bidirectional_iterator<Value,difference_type> {
                    protected:
                    link_type node;
                    const_iterator(link_type x) : node(x) {}
             };
             public:
                size_type count(const key_type& x) const;
             };
        template <class Key, class Value, class KeyOfValue,
                 class Compare>
                 rb_tree<Key, Value, KeyOfValue, Compare>::size_type
                 rb_tree<Key, Value, KeyOfValue, Compare>::
                 count(const Key& k) const {
                    size_type n = 0;
                    return n;
             };
             template <class Key, class Compare>   class set {
               typedef ::std::rb_tree<Key, Key,ident<Key, Key>, Compare>
                 rep_type;
          rep_type t;
     };

   }

   template <class Node, class Compare>class CAiTransitiveClosure{
   public:

      typedef std::set<Node, Compare > NodeSet; NodeSet m_todo;

   };

   template <class Node, class Compare> class CAiSpanningTree {
   public:

      typedef std::set<Node, Compare > NodeSet;

   protected:

      typedef Node CAiSpanningTreeNode;
      typedef NodeSet CAiSpanningTreeNodeSet;

   private:

      struct TransClosureNode {};
      struct TransClosureGraph
        : public CAiTransitiveClosure<TransClosureNode,

   std::less<TransClosureNode> >

      {};

   public:

      CAiSpanningTree(const Node& initialNode);
      CAiSpanningTree(const NodeSet& initialNodes);

   };

   struct State { };
   class CformSpanningTree:public CAiSpanningTree<State,std::less<State>>
   {
   public:

       CFormSpanningTree( NodeSet initial)
      : CAiSpanningTree<State, std::less<State> >(initial)
      {}

   };

Keywords : kbcode kbtool kbCompiler kbVC500bug kbVC600bug
Version : winnt:5.0,6.0
Platform : winnt
Issue type : kbbug
Technology : kbvc
"



Quote:
> Just ran across another post asking the same question... but pls let me
know
> if anybody else has any other tips.

> Thanks



Mon, 29 Sep 2003 14:45:48 GMT  
 getting rid of warning C4786
This is absolutely correct.  Most of the time, the #pragma will work, but
not all of the time.  Read the article for more details, but in general the
"pragma disable" approach is the way to go.


Quote:

> After _I_ added this #pragma, the warning never showed up again :-))

> But I just found THIS in the MSKB:

> "
> BUG: C4786 Warning Is Not Disabled with #pragma Warning

> --------------------------------------------------------------------------
--
> ----
> The information in this article applies to:

> Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0

> --------------------------------------------------------------------------
--
> ----

> SYMPTOMS
> Warnings similar to the following are generated even if you use the
warning
> pragma to disable the warning:

> warning C4786:
> 'std::rb_tree<CAiSpanningTree<State,std::less<State>>::TransClosureNode,
> CAiSpanningTree<State,std::less<State>>::TransClosureNode,std::ident<Cai
> SpanningTree<State,std::less<State>>::TransClosureNode,CAiSpanningTree<S
> tate,std::less<State>>::TransClosureNode>,std::less<CAiSpanningTree<Stat
> e,std::less<State>>::TransClosureNode>>' : identifier was truncated to
'255'
> characters in the debug information
> The code:

>    #pragma warning(disable:4786)
> disables warnings that list the file and line number. For example:

>    C:\test\Text.cpp(25) : warning C4786:

> STATUS
> Microsoft has confirmed this to be a bug in the Microsoft products listed
at
> the beginning of this article.

> MORE INFORMATION
> This warning can be ignored. However, the identifier may not be accessible
> or viewable in the de{*filter*}.

> Sample Code

>    /*
>    Compiler Options: /Zi
>    */

>    #include <stddef.h>
>    #include <new.h>
>    #pragma warning(disable:4786)

>    namespace std {

>       template <class T, class U>  struct ident {};
>       template <class T1, class T2> struct pair {};
>       template <class Arg1, class Arg2, class Result>
>          struct binary_function {};
>       template <class T>struct less : binary_function<T, T, bool> {};
>       template <class T, class Distance> struct bidirectional_iterator {};
>       template <class Key, class Value, class KeyOfValue, class Compare>
>         class rb_tree {
>           public:
>              typedef int size_type;
>              typedef int difference_type;
>              typedef void* link_type;
>              struct rb_tree_node {};
>              typedef Key key_type;
>              class iterator : public bidirectional_iterator<Value,
>                 difference_type> {};
>              class const_iterator   : public
>                 bidirectional_iterator<Value,difference_type> {
>                     protected:
>                     link_type node;
>                     const_iterator(link_type x) : node(x) {}
>              };
>              public:
>                 size_type count(const key_type& x) const;
>              };
>         template <class Key, class Value, class KeyOfValue,
>                  class Compare>
>                  rb_tree<Key, Value, KeyOfValue, Compare>::size_type
>                  rb_tree<Key, Value, KeyOfValue, Compare>::
>                  count(const Key& k) const {
>                     size_type n = 0;
>                     return n;
>              };
>              template <class Key, class Compare>   class set {
>                typedef ::std::rb_tree<Key, Key,ident<Key, Key>, Compare>
>                  rep_type;
>           rep_type t;
>      };

>    }

>    template <class Node, class Compare>class CAiTransitiveClosure{
>    public:

>       typedef std::set<Node, Compare > NodeSet; NodeSet m_todo;

>    };

>    template <class Node, class Compare> class CAiSpanningTree {
>    public:

>       typedef std::set<Node, Compare > NodeSet;

>    protected:

>       typedef Node CAiSpanningTreeNode;
>       typedef NodeSet CAiSpanningTreeNodeSet;

>    private:

>       struct TransClosureNode {};
>       struct TransClosureGraph
>         : public CAiTransitiveClosure<TransClosureNode,

>    std::less<TransClosureNode> >

>       {};

>    public:

>       CAiSpanningTree(const Node& initialNode);
>       CAiSpanningTree(const NodeSet& initialNodes);

>    };

>    struct State { };
>    class CformSpanningTree:public CAiSpanningTree<State,std::less<State>>
>    {
>    public:

>        CFormSpanningTree( NodeSet initial)
>       : CAiSpanningTree<State, std::less<State> >(initial)
>       {}

>    };

> Keywords : kbcode kbtool kbCompiler kbVC500bug kbVC600bug
> Version : winnt:5.0,6.0
> Platform : winnt
> Issue type : kbbug
> Technology : kbvc
> "



> > Just ran across another post asking the same question... but pls let me
> know
> > if anybody else has any other tips.

> > Thanks



Mon, 29 Sep 2003 23:13:07 GMT  
 getting rid of warning C4786
I read the article, but it says to use #pragma warning(disable:4786) which
I'm doing, but warnings still show up. Is there something I'm missing from
this article?


Quote:

> After _I_ added this #pragma, the warning never showed up again :-))

> But I just found THIS in the MSKB:



Tue, 30 Sep 2003 00:16:16 GMT  
 getting rid of warning C4786
You may have an empty source file (stdafx.cpp) that includes the file with
the offending symbol name.
Try adding a stub function in the empty source file & the warning will go
away. For example:

namespace
{
    void GoAway4786() {}

Quote:
}



Quote:
> I read the article, but it says to use #pragma warning(disable:4786) which
> I'm doing, but warnings still show up. Is there something I'm missing from
> this article?



> > After _I_ added this #pragma, the warning never showed up again :-))

> > But I just found THIS in the MSKB:



Tue, 30 Sep 2003 05:39:49 GMT  
 getting rid of warning C4786
The #pragma warning(disable:4786) works, but you have to put it in the
source prior to absolutely
all stl #includes.  Just make it the first thing in the file.  This is how
it is done in the STL samples.
I discovered this by trial and error, but I believe the answer is also
somewhere in the MSDN library.


Quote:
> You may have an empty source file (stdafx.cpp) that includes the file with
> the offending symbol name.
> Try adding a stub function in the empty source file & the warning will go
> away. For example:

> namespace
> {
>     void GoAway4786() {}
> }



> > I read the article, but it says to use #pragma warning(disable:4786)
which
> > I'm doing, but warnings still show up. Is there something I'm missing
from
> > this article?



> > > After _I_ added this #pragma, the warning never showed up again :-))

> > > But I just found THIS in the MSKB:



Wed, 01 Oct 2003 06:45:45 GMT  
 getting rid of warning C4786
I have several compiler warnings that I always want off because of coding
conventions that I use regularly. I use /FImscprag.h on the compiler command
line in my make file (or project settings), then add my list of #pragma
warning(disable:xxxx) lines to this file. The /FI force includes this file
before any others in all compiled files.

John


Quote:
> Hello,

> Can somebody give me some pointers of how to get rid of those damn C4786
> warnings?  I've added a bunch of #pragma warning (disable:4786) but these
> things keep showing up.  How can I track down what is causing these
warnings
> (the warnings have to be the most cryptic things I've ever seen)?  Where
> exactly should I be placing my #pragma disables?

> Any advice would be greatly appreciated.

> Thanks,
> Andrew



Tue, 07 Oct 2003 07:11:39 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. warning C4786: STL template warnings

2. Getting rid of VC++ Compiler warnings

3. Getting rid of VC++ Compiler warnings

4. Getting rid of warning 4284!

5. Real Work Around for Compiler Warning C4786 ?

6. Workaround for Compiler Warning C4786?

7. Warning C4786

8. warning C4786

9. Warning C4786 --- URGENT ---Please have a look

10. warning C4786 when compiling debug version of Stroustrup's calculator

11. Warning C4786

12. Q: VC6, still warning C4786 ?

 

 
Powered by phpBB® Forum Software