Opened 14 years ago

Closed 14 years ago

#2427 closed Bugs (invalid)

message_queue uses deprecated function in VS 8.0

Reported by: Tom Kent <teeks99@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc:

Description

There is a usage of a deprecated function in Visual Studio 8.0 (2005) when using the message_queue in the interprocess library. However, this ONLY manifests itself when there is a #include <string> BEFORE the #include <boost/interprocess/ipc/message_queue.hpp>. If the string include is after the message_queue include, everything compiles fine.

For example:

#include <string>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <iostream>

int main(int argc, char* argv[])
{
   boost::interprocess::message_queue* rcv;
   std::string exampleString = "Hi";

   std::cout << exampleString << &rcv << std::endl;
   return 0;
}

returns the warning

1>BoostMessageQueueTest.cpp
1>c:\program files\microsoft visual studio 8\vc\include\xutility(2404) : warning C4996: 'std::_Copy_backward_opt' 
was declared deprecated
1>        c:\program files\microsoft visual studio 8\vc\include\xutility(2391) : see declaration of 
'std::_Copy_backward_opt'
1>        Message: 'You have used a std:: construct that is not safe. See documentation on how to use the Safe 
Standard C++ Library'
1>        e:\boost building\boost_1_36_0\boost\interprocess\ipc\message_queue.hpp(270) : see reference to 
function template instantiation '_BidIt2
 std::copy_backward<boost::interprocess::detail::mq_hdr_t::
msg_hdr_ptr_t*,boost::interprocess::detail::mq_hdr_t::msg_hdr_ptr_t*>(_BidIt1,_BidIt1,_BidIt2)' being compiled
1>        with
1>        [
1>            _BidIt2=boost::interprocess::detail::mq_hdr_t::msg_hdr_ptr_t *,
1>            _BidIt1=boost::interprocess::detail::mq_hdr_t::msg_hdr_ptr_t *
1>        ]

however if I do:

#include <boost/interprocess/ipc/message_queue.hpp>
#include <string>
#include <iostream>

int main(int argc, char* argv[])
{
   boost::interprocess::message_queue* rcv;
   std::string exampleString = "Hi";

   std::cout << exampleString << &rcv << std::endl;
   return 0;
}

then everything builds without any warnings.

Change History (1)

comment:1 by Ion Gaztañaga, 14 years ago

Resolution: invalid
Status: newclosed

This is not a bug. Microsoft deprecates by default many STL algorithms. This is disabled by internal interprocess headers in detail/config_begin.hpp. Some interprocess headers include <string> so trying to reinclude it after has no effect.

Sadly, it's programmers job to define _CRT_SECURE_NO_DEPRECATE in the project to avoid this annoying warning.

Note: See TracTickets for help on using tickets.