English 中文(简体)
Cannot 编成4.6.1
原标题:Cannot compile code with gcc 4.6.1
  • 时间:2011-10-27 15:45:40
  •  标签:
  • c++
  • gcc
  • boost

下面的该法典将罚款与VS2010汇编成册,但并不希望汇编4.6.1。

#ifndef IS_CHAR_H_INCLUDED
#define IS_CHAR_H_INCLUDED
#include <type_traits>

template<class Int_T>
struct Is_Char_
{
    enum {value = false};
};

template<>
struct Is_Char_<char>
{
    enum {value = true};
};

template<>
struct Is_Char_<unsigned char>
{
    enum {value = true};
};

template<>
struct Is_Char_<signed char>
{
    enum {value = true};
};

template<class Int_T>
struct Is_Char : Is_Char_<typename std::remove_cv<Int_T>::type>
{

};

#endif // IS_CHAR_H_INCLUDED

#ifndef PROMOTE_H_INCLUDED
#define PROMOTE_H_INCLUDED
#include <type_traits>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/end.hpp>
   //#include "Is_Char.h" doesn t have to be here this file is pasted above


/*Promotes Integer type to one up in size range*/
template<class Integer>
struct Promote
{
    static_assert(std::is_integral<Integer>::value,"Non Integer type is not allowed.");
    /*Check correct type - depending on Integer being signed or unsigned*/
    typedef typename std::conditional<std::is_signed<Integer>::value,
                                boost::mpl::vector<signed char,short,int,long,long long>,
    boost::mpl::vector<unsigned char,unsigned short,unsigned int,long,long long>
                                     >::type types;
    /*
    Find this type from the list above - substituting Integer for signed or unsigned char iff Integer is of type char
    */
    typedef typename boost::mpl::find<types,
    typename std::conditional<Is_Char<Integer>::value,
    typename std::conditional<std::is_signed<Integer>::value,signed char,unsigned char>::type, Integer>::type>::type this_type;

    /*If Integer is int and if size of it is == to long promote int to long long (iterate to next element twice)*/
    typedef typename boost::mpl::eval_if<boost::mpl::bool_<((std::is_same<Integer,int>::value || std::is_same<Integer,unsigned int>::value)
                                                                && (sizeof(int) == sizeof(long)))>,
                                         boost::mpl::next<typename boost::mpl::next<this_type>::type>,
                                         boost::mpl::next<this_type>
                                        >::type next_type;
    /*Check if iterator points within range or if one pass end which means that Integer was u/long long*/
    typedef typename std::conditional<std::is_same<typename boost::mpl::end<types>::type,next_type>::value,Integer,typename boost::mpl::deref<next_type>::type>::type type;
};

#endif // PROMOTE_H_INCLUDED
最佳回答

My guess is You re not specified -std=c++0x 编篡时,C++11的特征,如<编码>std:is_integral<> aren t available。 当我使用这一选择时,你的法典为我编纂。

UPDATE:现在,你已经展示了汇编者的产出,问题是,你能够仅仅了解每一个可能的警告,并且还建立了<代码>-加速-errors<<>,将其中一些内容作为错误处理。 这些警告中有许多是由完全明智的法典所引发的,大多数作者(包括博斯特)赢得一定时间,以安抚或工作。

您当然应当删除<代码>-加速-errors,除非你有特别要求,任何法典都不得使用编篡人专用的延伸;在这种情况下,你可能不会使用“诱杀”。 或许也是解除一些不太有用的警告的好想法——你可以确定诱发的警告,因此,它们这样做就更难以发现对你的守则的真正警告。 我通常的目的是用<代码>-Wall-Wextra进行清理。

问题回答

真正的问题不在你的法典中。 问题是,你可以发现编辑的错误信息。 你们面前的这个问题怎么说!

在一个终点站内运行准确的<代码>g++/代码>。 那么,你就会看到错误。 承诺为此使用一个民主选举学会。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?