让gcc支持成员函数模板的trick 罗朝辉 (http://www.cnblogs.com/kesalin/) 本文遵循“署名-非商业用途-保持一致”创作公用协议 gcc 4.7.3 不支持成员函数模板特化.如下代码: #ifndef __MEMFUNTEMPLATE_H__ #define __MEMFUNTEMPLATE_H__ #include <stdio.h> class Base {}; class Derived : public Base {}; struct Fun
configure: error: *** A compiler with support for C++11 language features is required. 参考链接: (1)升级 GCC 支持C++11. (2)解决/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found的问题方法总结. 一.错误发生情景: 使用sh setup.sh安装软件时,报以下错误: ... configure: error: *** A c
__attribute__实际上是gcc专有的一种语法,是用来设置函数属性.变量属性.类属性的 语法:之前在C中的结构体对齐中提到过,当时是用来告诉编译器这个结构体的对齐方式 ,其实他还有很多种用法,可以设置很多的属性.语法: __attribute__ (parameter)对于变量: int a __attribute__ ((xxxxx)) = 10; //也可以放在变量的前面,比较灵活 int a __attribute__ ((xxxxx)); // 也可以放在变量的前面,比较灵活对于
在Linux中,如果man -s2 open, 我们看到两种不同的函数原型声明: $ man -s2 open NAME open, creat - open and possibly create a file or device SYNOPSIS #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int open(const char *pathname, int flags); int
在C/C++中,为了避免同一个文件被include多次,有两种方式:一种是#ifndef方式,一种是#pragma once方式(在头文件的最开始加入). #ifndef SOME_UNIQUE_NAME_HERE #define SOME_UNIQUE_NAME_HERE // contents of the header ... #endif // SOME_UNIQUE_NAME_HERE #pragma once // contents of the header ... #ifndef