ubuntu 18.04 内核版本(linuxgcc命令怎么使用)

生活常识 2023-05-15 19:41生活常识www.xinxueguanw.cn

g1720和g1721的差别 跟老韩学Ubuntu Server 2204-gcc指令帮助手册09节

GCC是每个从事Linux,以及嵌入式开发等必备的编译器,由于帮助手册较多,这里使用了分页的形式进行分享,如下为Ubuntu Server 22.04操作系统平台和GCC编译器的基本信息。

老韩Linux架构师系列

GCC帮助手册的第9小节,第1688~1888行。

1688 }1689 The compiler rearranges the member initializers for #34i#34 and #34j#34 to match the declaration order of the1690 members, emitting a warning to that effect. This warning is enabled by -Wall.1691 -Wno-pessimizing-move (C++ and Objective-C++ only)1692 This warning warns when a call to #34std::move#34 prevents copy elision. A typical scenario when copy elision1693 can occur is when returning in a function with a class return type, when the expression being returned is1694 the name of a non-volatile automatic object, and is not a function parameter, and has the same type as the1695 function return type.1696 struct T {1697 ...1698 }1699 T fn()1700 {1701 T t1702 ...1703 return std::move (t)1704 }1705 But in this exle, the #34std::move#34 call prevents copy elision.1706 This warning is enabled by -Wall.1707 -Wno-redundant-move (C++ and Objective-C++ only)1708 This warning warns about redundant calls to #34std::move#34 that is, when a move operation would have been1709 performed even without the #34std::move#34 call. This happens because the compiler is forced to treat the1710 object as if it were an rvalue in certain situations such as returning a local variable, where copy elision1711 isn#39t applicable. Consider:1712 struct T {1713 ...1714 }1715 T fn(T t)1716 {1717 ...1718 return std::move (t)1719 }1720 Here, the #34std::move#34 call is redundant. Because G++ implements Core Issue 1579, another exle is:1721 struct T { // convertible to U1722 ...1723 }1724 struct U {1725 ...1726 }1727 U fn()1728 {1729 T t1730 ...1731 return std::move (t)1732 }1733 In this exle, copy elision isn#39t applicable because the type of the expression being returned and the1734 function return type differ, yet G++ treats the return value as if it were designated by an rvalue.1735 This warning is enabled by -Wextra.1736 -Wrange-loop-construct (C++ and Objective-C++ only)1737 This warning warns when a C++ range-based for-loop is creating an unnecessary copy. This can happen when1738 the range declaration is not a reference, but probably should be. For exle:1739 struct S { char arr[128] }1740 void fn () {1741 S arr[5]1742 for (const auto x : arr) { ... }1743 }1744 It does not warn when the type being copied is a trivially-copyable type whose size is less than 64 bytes.1745 This warning also warns when a loop variable in a range-based for-loop is initialized with a value of a1746 different type resulting in a copy. For exle:1747 void fn() {1748 int arr[10]1749 for (const double x : arr) { ... }1750 }1751 In the exle above, in every iteration of the loop a temporary value of type #34double#34 is created and1752 destroyed, to which the reference #34const double #34 is bound.1753 This warning is enabled by -Wall.1754 -Wredundant-tags (C++ and Objective-C++ only)1755 Warn about redundant class-key and enum-key in references to class types and enumerated types in contexts1756 where the key can be eliminated without causing an ambiguity. For exle:1757 struct foo1758 struct foo p // warn that keyword struct can be eliminated1759 On the other hand, in this exle there is no warning:1760 struct foo1761 void foo () // #34hides#34 struct foo1762 void bar (struct foo) // no warning, keyword struct is necessary1763 -Wno-subobject-linkage (C++ and Objective-C++ only)1764 Do not warn if a class type has a base or a field whose type uses the anonymous namespace or depends on a1765 type with no linkage. If a type A depends on a type B with no or internal linkage, defining it in multiple1766 translation units would be an ODR violation because the meaning of B is different in each translation unit.1767 If A only appears in a single translation unit, the best way to silence the warning is to give it internal1768 linkage by putting it in an anonymous namespace as well. The compiler doesn#39t give this warning for types1769 defined in the main .C file, as those are unlikely to have multiple definitions. -Wsubobject-linkage is1770 enabled by default.1771 -Weffc++ (C++ and Objective-C++ only)1772 Warn about violations of the following style guidelines from Scott Meyers#39 Effective C++ series of books:1773 Define a copy constructor and an assignment operator for classes with dynamically-allocated memory.1774 Prefer initialization to assignment in constructors.1775 Have #34operator=#34 return a reference to this.1776 Don#39t try to return a reference when you must return an object.1777 Distinguish between prefix and postfix forms of increment and decrement operators.1778 Never overload #34#34, #34||#34, or #34,#34.1779 This option also enables -Wnon-virtual-dtor, which is also one of the effective C++ recommendations.1780 However, the check is extended to warn about the lack of virtual destructor in accessible non-polymorphic1781 bases classes too.1782 When selecting this option, be aware that the standard library headers do not obey all of these guidelines1783 use grep -v to filter out those warnings.1784 -Wno-exceptions (C++ and Objective-C++ only)1785 Disable the warning about the case when an exception handler is shadowed by another handler, which can1786 point out a wrong ordering of exception handlers.1787 -Wstrict-null-sentinel (C++ and Objective-C++ only)1788 Warn about the use of an uncasted #34NULL#34 as sentinel. When compiling only with GCC this is a valid1789 sentinel, as #34NULL#34 is defined to #34__null#34. Although it is a null pointer constant rather than a null1790 pointer, it is guaranteed to be of the same size as a pointer. But this use is not portable across1791 different compilers.1792 -Wno-non-template-friend (C++ and Objective-C++ only)1793 Disable warnings when non-template friend functions are declared within a template. In very old versions1794 of GCC that predate implementation of the ISO standard, declarations such as friend int foo(int), where the1795 name of the friend is an unqualified-id, could be interpreted as a particular specialization of a template1796 function the warning exists to diagnose compatibility problems, and is enabled by default.1797 -Wold-style-cast (C++ and Objective-C++ only)1798 Warn if an old-style (C-style) cast to a non-void type is used within a C++ program. The new-style casts1799 (#34dynamic_cast#34, #34static_cast#34, #34reinterpret_cast#34, and #34const_cast#34) are less vulnerable to unintended1800 effects and much easier to search for.1801 -Woverloaded-virtual (C++ and Objective-C++ only)1802 Warn when a function declaration hides virtual functions from a base class. For exle, in:1803 struct A {1804 virtual void f()1805 }1806 struct B: public A {1807 void f(int)1808 }1809 the #34A#34 class version of #34f#34 is hidden in #34B#34, and code like:1810 B b1811 b-gtf()1812 fails to compile.1813 -Wno-pmf-conversions (C++ and Objective-C++ only)1814 Disable the diagnostic for converting a bound pointer to member function to a plain pointer.1815 -Wsign-promo (C++ and Objective-C++ only)1816 Warn when overload resolution chooses a promotion from unsigned or enumerated type to a signed type, over a1817 conversion to an unsigned type of the same size. Previous versions of G++ tried to preserve unsignedness,1818 but the standard mandates the current behavior.1819 -Wtemplates (C++ and Objective-C++ only)1820 Warn when a primary template declaration is encountered. Some coding rules disallow templates, and this1821 may be used to enforce that rule. The warning is inactive inside a system header file, such as the STL, so1822 one can still use the STL. One may also instantiate or specialize templates.1823 -Wno-mi atched-new-delete (C++ and Objective-C++ only)1824 Warn for mi atches between calls to #34operator new#34 or #34operator delete#34 and the corresponding call to the1825 allocation or deallocation function. This includes invocations of C++ #34operator delete#34 with pointers1826 returned from either mi atched forms of #34operator new#34, or from other functions that allocate objects for1827 which the #34operator delete#34 isn#39t a suitable deallocator, as well as calls to other deallocation functions1828 with pointers returned from #34operator new#34 for which the deallocation function isn#39t suitable.1829 For exle, the #34delete#34 expression in the function below is diagnosed because it doesn#39t match the array1830 form of the #34new#34 expression the pointer argument was returned from. Similarly, the call to #34free#34 is also1831 diagnosed.1832 void f ()1833 {1834 int a = new int[n]1835 delete a // warning: mi atch in array forms of expressions1836 char p = new char[n]1837 free (p) // warning: mi atch between new and free1838 }1839 The related option -Wmi atched-dealloc diagnoses mi atches involving allocation and deallocation1840 functions other than #34operator new#34 and #34operator delete#34.1841 -Wmi atched-new-delete is enabled by default.1842 -Wmi atched-tags (C++ and Objective-C++ only)1843 Warn for declarations of structs, classes, and class templates and their specializations with a class-key1844 that does not match either the definition or the first declaration if no definition is provided.1845 For exle, the declaration of #34struct Object#34 in the argument list of #34draw#34 triggers the warning. To1846 avoid it, either remove the redundant class-key #34struct#34 or replace it with #34class#34 to match its1847 definition.1848 class Object {1849 public:1850 virtual ~Object () = 01851 }1852 void draw (struct Object)1853 It is not wrong to declare a class with the class-key #34struct#34 as the exle above shows. The1854 -Wmi atched-tags option is intended to help achieve a consistent style of class declarations. In code1855 that is intended to be portable to Windows-based compilers the warning helps prevent unresolved references1856 due to the difference in the mangling of symbols declared with different class-keys. The option can be1857 used either on its own or in conjunction with -Wredundant-tags.1858 -Wmultiple-inheritance (C++ and Objective-C++ only)1859 Warn when a class is defined with multiple direct base classes. Some coding rules disallow multiple1860 inheritance, and this may be used to enforce that rule. The warning is inactive inside a system header1861 file, such as the STL, so one can still use the STL. One may also define classes that indirectly use1862 multiple inheritance.1863 -Wvirtual-inheritance1864 Warn when a class is defined with a virtual direct base class. Some coding rules disallow multiple1865 inheritance, and this may be used to enforce that rule. The warning is inactive inside a system header1866 file, such as the STL, so one can still use the STL. One may also define classes that indirectly use1867 virtual inheritance.1868 -Wno-virtual-move-assign1869 Suppress warnings about inheriting from a virtual base with a non-trivial C++11 move assignment operator.1870 This is dangerous because if the virtual base is reachable along more than one path, it is moved multiple1871 times, which can mean both objects end up in the moved-from state. If the move assignment operator is1872 written to avoid moving from a moved-from object, this warning can be disabled.1873 -Wnamespaces1874 Warn when a namespace definition is opened. Some coding rules disallow namespaces, and this may be used to1875 enforce that rule. The warning is inactive inside a system header file, such as the STL, so one can still1876 use the STL. One may also use using directives and qualified names.1877 -Wno-terminate (C++ and Objective-C++ only)1878 Disable the warning about a throw-expression that will immediately result in a call to #34terminate#34.1879 -Wno-vexing-parse (C++ and Objective-C++ only)1880 Warn about the most vexing parse syntactic ambiguity. This warns about the cases when a declaration looks1881 like a variable definition, but the C++ language requires it to be interpreted as a function declaration.1882 For instance:1883 void f(double a) {1884 int i() // extern int i (void)1885 int n(int(a)) // extern int n (int)1886 }

加油,做更好的自己。

linuxgcc命令怎么使用 centos ubuntu debian 区别

Copyright@2015-2025 www.xinxueguanw.cn 心血管健康网版板所有