[Bf-committers] Re: MEM_CacheLimiter breaks msvc6
compile repairable!
bjornmose
bjornmose at gmx.net
Thu Feb 9 22:22:33 CET 2006
Hey Peter,
ahh .. you did choose the knitpicking way ( good .. i hate code
duplication too )
looks good here:
-mcvc6 (projects) compiles
-v7 (scons) is fine too
cheers ole
Peter Schlaile wrote:
> Hi Ole,
>
> could you try the attached patch, that should detect MSVC6.0 and make it
> compile. Any suggestions welcome. (Could also others try this with newer
> versions of MSVC++ etc. so that I do not ruin anyone's day by commiting
> it...)
>
> Greetings,
> Peter
>
>
>
>
> ------------------------------------------------------------------------
>
> Index: MEM_Allocator.h
> ===================================================================
> RCS file: /cvsroot/bf-blender/blender/intern/memutil/MEM_Allocator.h,v
> retrieving revision 1.1
> diff -u -r1.1 MEM_Allocator.h
> --- MEM_Allocator.h 5 Feb 2006 18:56:27 -0000 1.1
> +++ MEM_Allocator.h 9 Feb 2006 20:19:53 -0000
> @@ -29,6 +29,12 @@
>
> #include "guardedalloc/MEM_guardedalloc.h"
>
> +#ifdef _MSC_VER
> +#if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost
> +#define MS_VISUALC_6_0_WORKAROUND 1
> +#endif
> +#endif
> +
> template<typename _Tp>
> struct MEM_Allocator
> {
> @@ -40,16 +46,20 @@
> typedef const _Tp& const_reference;
> typedef _Tp value_type;
>
> +#ifndef MS_VISUALC_6_0_WORKAROUND
> template<typename _Tp1>
> struct rebind {
> typedef MEM_Allocator<_Tp1> other;
> };
> +#endif
>
> MEM_Allocator() throw() {}
> MEM_Allocator(const MEM_Allocator& __a) throw() {}
>
> +#ifndef MS_VISUALC_6_0_WORKAROUND
> template<typename _Tp1>
> MEM_Allocator(const MEM_Allocator<_Tp1> __a) throw() { }
> +#endif
>
> ~MEM_Allocator() throw() {}
>
> @@ -57,6 +67,11 @@
>
> const_pointer address(const_reference __x) const { return &__x; }
>
> +#ifdef MS_VISUALC_6_0_WORKAROUND
> + char *_Charalloc(size_type n) {
> + return (char *) MEM_mallocN(n, "STL MEM_Allocator VC6.0");
> + }
> +#endif
> // NB: __n is permitted to be 0. The C++ standard says nothing
> // about what the return value is when __n == 0.
> _Tp* allocate(size_type __n, const void* = 0) {
> @@ -68,10 +83,17 @@
> return __ret;
> }
>
> +#ifndef MS_VISUALC_6_0_WORKAROUND
> // __p is not permitted to be a null pointer.
> void deallocate(pointer __p, size_type){
> MEM_freeN(__p);
> }
> +#else
> + // __p is not permitted to be a null pointer.
> + void deallocate(void* __p, size_type){
> + MEM_freeN(__p);
> + }
> +#endif
>
> size_type max_size() const throw() {
> return size_t(-1) / sizeof(_Tp);
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
More information about the Bf-committers
mailing list