Solution to Macro redefinition error when using Boost library in VS (warning C4005)

Source: Internet
Author: User

Recently, I used the Boost library for multi-thread development. It is visible that the compilation engineers in vs always encounter Macro redefinition errors, similar to the following error description.

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdint.h(116): warning C4005: 'INT8_C' : macro redefinition1>          c:\vc\include\boost\cstdint.hpp(376) : see previous definition of 'INT8_C'

At the beginning, I was not responsible for it. It was obvious that this was a slow Compilation speed, so I couldn't bear it. I decided to google it. I found someone in boost had submitted the bug and the status was fixed, refer to the following link

Ticket #4182

The following reply says that the macro "BOOST_HAS_STDINT_H" needs to be defined in the config file to solve the problem. However, I have not worked in this experiment for a long time, and then I want to fix Changeset 62082, the file below is modified.

boost/config/compiler/visualc.hpp

Then I checked my own file and found that it was fixed. But why is there an error? So I tried to comment it out.

#  define BOOST_HAS_STDINT_H

Then re-compile and solve the problem,

So the final solution is:

Modify the vc compiler configuration file "boost/config/compiler/visualc. hpp" and comment out the macro definition "BOOST_HAS_STDINT_H" to solve the problem.

#if _MSC_VER >= 1600//#  define BOOST_HAS_STDINT_H#endif

Or you can completely comment out the rows.

 

The principle of such modification is speculative: it should be that Microsoft's vc compiler files have also handled this problem, resulting in both parties simultaneously modifying the macro definition, resulting in the same macro definition is still not modified, the file is repeatedly included.


This work is licensed using the knowledge sharing signature-non-commercial use-share the 4.0 international license agreement in the same way.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.