English 中文(简体)
flag的旗帜是什么?
原标题:What does the fpermissive flag do?

我很想知道,<代码>-fpermissive的旗帜在“g++”汇编者中有何作用? 我正在获悉:

错误:处理临时[赠与]

which I can solve by giving the -fpermissive flag to the compiler.

EDIT: I just found what was causing the temporary address error part! I m going to fix that part right now.

最佳回答

Right from The docs:

-fpermissive
Downgrade some diagnostics about nonconformant code from errors to warnings. Thus, using -fpermissive will allow some nonconforming code to compile.

底层:don t use 除非你知道你正在做些什么,否则就是这样做的。

问题回答

The -fpermissive flag causes the compiler to report some things that are actually errors (but are permitted by some compilers) as warnings, to permit code to compile even if it doesn t conform to the language rules. You really should fix the underlying problem. Post the smallest, compilable code sample that demonstrates the problem.

-fpermissive
Downgrade some diagnostics about nonconformant code from errors to warnings. Thus, using -fpermissive will allow some nonconforming code to compile.

当你写出语文标准允许的那条n时(因此,实际上可能是明确的行为,这足以说明原因),但是,如果在编造引擎上 fed,那么<代码>-fpermissive就只能是这样,而不是用这个错误的信息加以阻止。 在某些情况下,方案会像你原先打算的那样具体实施,但除非你有某种特别理由不使用其他解决办法,否则你肯定不会依赖该方案。

如果你想要一个真正的世界使用案例,则试图汇编一个非常旧的XWindows-说书,即XFree86或XOrg,从2004年的一艘船,在使用4.9.3等“Modern”(cough)版本的分门面。

You ll notice the build CFLAGS specify both "-ansi" and "-pedantic". In theory, this means, "blow up if anything even slightly violates the language spec". In practice, the 3.x series of gcc didn t catch very much of that kind of stuff, and building it with 4.9.3 will leave a smoking hole in the ground unless you set CFLAGS and BOOTSTRAPCFLAGS to "-fpermissive".

利用这一旗帜,这些C文件多数将实际建立起来,使你可以自由进入依赖该国旗的码头。

一个简单地设置——放任和不夸张的普通案例是:经过彻底测试和运行的第三方图书馆,这些图书馆在编篡新版本时,没有——允许。 这些图书馆已经存在,而且很可能不是申请开发商要解决的问题,也不是开发商的日程安排。

Set - fpermissive and movement on that case.

一般答案是,它“从错误到警告”对不符合同的代码进行一些诊断

不幸的是,我没有看到它允许的具体清单。

我的答复的主要原因是,建议你尽可能避免使用。 相反,研究每一种错误,看看看是否可以确定。 注册处发现并确定了造成错误的原因。 (“选择临时地址”可能像要求一种功能,这种功能可以恢复:扼制物体,将一些东西分配到瞬间物体的值。)

I was just reviewing a project that involved upgrading the version of gcc, and the developer added -fpermissive because there were suddenly a bunch of compilation errors. I noticed that one test was:

    if (myPointer ==   )

我指出,这确实应当是:

    if (myPointer[0] ==   )

该开发商进行了检查,发现每件单件旗帜都是一个真正的错误,其中一部分已经存在20多年。

As @cli_hlt referred

底层:除非你知道你正在做什么,否则不会使用。

它可以做可怕的事情,这样,汇编者有时可以取消<代码>以下的变量的含意:地图:

#include <map>
#include <vector>
#include <iostream>
#include <string>
struct B{
    std::map<std::string, int> m_map;
    std::vector<int> m_vector;
    B(){
        m_map["a"] = 1;
        m_map["b"] = 2;
        m_map["c"] = 3;
        m_vector.emplace_back(1);
        m_vector.emplace_back(2);
        m_vector.emplace_back(3);
    }
    const std::map<std::string, int>& getMap() const {
        return m_map;
    }
    const int& getMapValue(const std::string& key) const {
        return m_map.at(key);
    }
    const std::vector<int>& getVector() const {
        return m_vector;
    }
    const int& getVectorValue(const int& i) const {
        return m_vector[i];
    }
};

int main(){
    B b;
    auto& my_map = b.getMap(); // we get const ref here
    my_map["a"] = 10; // here we can modify it
    std::cout << "my_map[a]=" << my_map.at("a") << std::endl;

    auto& my_map2 = b.getMap();  // here we return already modified variable
    std::cout << "my_map2[a]=" << my_map2.at("a") << std::endl;

    auto& my_value = b.getMapValue("b");
    // my_value = 20; // compiler error
    // std::cout << "my_map[b]=" << my_value << std::endl;

    auto& my_vector = b.getVector();
    // my_vector[0] = 10; // compiler error
    // std::cout << "my_vector[0]=" << my_vector[0] << std::endl;

    const int a = 10;
    auto& a1 = a;
    // a1 = 100; // compiler error
}

As you can see you can t guarantee the constness of the map, however, the constness of a vector or value can be preserved. P.S. here I tested in the following compilers GCC 12.1, 9.1, 8.1, 7.1, 6.1. However, clang does not -fpermissive flag have this and it will catch the error.





相关问题
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?

热门标签