Ticket #12375: 0001-Allow-compilation-on-MSVC-with-P.patch

File 0001-Allow-compilation-on-MSVC-with-P.patch, 2.4 KB (added by anonymous, 6 years ago)

Patch against boost::icl

  • include/boost/icl/detail/element_iterator.hpp

    From 3c59f2bf5eadb066dd97c07652506594054c1cc6 Mon Sep 17 00:00:00 2001
    From: nil <nil@ableton.com>
    Date: Wed, 3 Aug 2016 12:38:09 +0200
    Subject: [PATCH] Allow compilation on MSVC with /P
    
    This patch makes it possible to use this header in programs built using
    the FASTbuild (http://fastbuild.org) and more precisely its caching
    feature.
    
    Considering the following code:
    
    clmacro.cpp:
    ```c++
    int main(void)
    {
    #define funny_type(x) x
    funny_type(int)const a = 2; // cl.exe -P clmacro.cpp -> `intconst a`
    }
    ```
    
    On MSVC (Visual Studio 2013)
    Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x86
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    This compiles correctly by default with `CL.exe`
    
    ```
    Cl.exe clmacro.cpp
    ```
    
    However when using the `/P` compilation flag to obtain the pre-processed
    source, then trying to compile the resulting file this will fail because
    const gets stitched to the other symbol before compilation.
    
    See:
    
    ```
    cl.exe -P -Ficlmacro.i.cpp clmacro.cpp && cl.exe clmacro.i.cpp
    ```
    ---
     include/boost/icl/detail/element_iterator.hpp | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/include/boost/icl/detail/element_iterator.hpp b/include/boost/icl/detail/element_iterator.hpp
    index 111f209..0d813fa 100644
    a b struct elemental;  
    113113    };
    114114
    115115    template< class CodomainT, ICL_INTERVAL(ICL_COMPARE) Interval >
    116     struct elemental<std::pair<ICL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
     116    struct elemental<std::pair<ICL_INTERVAL_TYPE(Interval,DomainT,Compare) const, CodomainT> >
    117117    {
    118118        typedef std::pair<ICL_INTERVAL_TYPE(Interval,DomainT,Compare), CodomainT> segment_type;
    119119        typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare)                       interval_type;
    struct segment_adapter  
    214214};
    215215
    216216template < class SegmentIteratorT, class CodomainT, ICL_INTERVAL(ICL_COMPARE) Interval >
    217 struct segment_adapter<SegmentIteratorT, std::pair<ICL_INTERVAL_TYPE(Interval,DomainT,Compare)const, CodomainT> >
     217struct segment_adapter<SegmentIteratorT, std::pair<ICL_INTERVAL_TYPE(Interval,DomainT,Compare) const, CodomainT> >
    218218{
    219219    typedef segment_adapter                                type;
    220220    typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare)    interval_type;