I am trying to compile a small c++ program using clang with the default C++ standard library(4.6.2) on Fedora. Clang itself compiles okay and a test program using only compiles and runs fine. My other program uses ropes which clang complains about. /usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/ext/ropeimpl.h:433:2: error: use of undeclared identifier '_Data_allocat
我想用Fedora上的默认C ++标准库(4.6.2)编译一个小型的c ++程序。 铿锵本身编译好,只使用编译和运行良好的测试程序。 我的其他程序使用clang抱怨的绳索。 /usr/lib/gcc/x86_64-redhat-linux/4.6.2/../../../../include/c++/4.6.2/ext/ropeimpl.h:433:2:error:use未声明的标识符'_Data_allocate'_Data_allocate(_S_rounded_up_size(__ old_len + __len)); 针对此错误消息提交了针对叮当的错误,并且解析
The section $3.6.1/1 from the C++ Standard reads, A program shall contain a global function called main , which is the designated start of the program. Now consider this code, int square(int i) { return i*i; } int user_main() { for ( int i = 0 ; i < 10 ; ++i ) std::cout << square(i) << endl; return 0; } int main_ret= user_main(); int main() { retur
来自C ++标准的$ 3.6.1 / 1部分读取, 程序应包含一个名为main的全局函数,它是程序的指定开始 。 现在考虑这个代码, int square(int i) { return i*i; } int user_main() { for ( int i = 0 ; i < 10 ; ++i ) std::cout << square(i) << endl; return 0; } int main_ret= user_main(); int main() { return main_ret; } 这个示例代码执行我打算做的事情,即在输入main()函
I'm trying to compile a c++ program, which is something I didn't do for a long time... What I'm trying is: g++ -c A.cpp -o A.o g++ -c dir/B.h -o B.o which seem to work, and then I try: g++ A.o B.o -o A -lX11 -lpthread and get: Bo: file not recognized: File format not recognized collect2: ld returned 1 exit status What is the problem? Thanks a lot :) Omit the -o argum
我试图编译一个c ++程序,这是我很久没有做的事情了...... 我正在尝试的是: g++ -c A.cpp -o A.o g++ -c dir/B.h -o B.o 这似乎工作,然后我尝试: g++ A.o B.o -o A -lX11 -lpthread 并得到: Bo:文件无法识别:文件格式无法识别 collect2:ld返回1退出状态 问题是什么? 非常感谢 :) 当你编译bh时省略-o参数,你很可能会看到g ++创建了一个名为bhgch而不是bo的文件。该文件是一个“预编译头文件”。 通过
In C, we have to use a struct prefix whenever we want to declare or define a structure. However, things have been changed once the structure became a kind of a class in c++. We no longer need to use a struct prefix when we declare a structure. In this vein, I guess the structure tag in C became a name of a type in C++ . However, it does not mean that we can't use a struct prefix. We sti
在C中,每当我们声明或定义一个结构时,我们都必须使用一个结构体前缀。 然而,一旦结构成为c ++中的一类,事情就会发生改变。 我们在声明结构时不再需要使用struct前缀。 在这种情况下,我猜C的结构标记成为C++的一个类型的名称。 但是,这并不意味着我们不能使用struct前缀。 我们仍然可以使用struct前缀。 例如,C ++的创建者Bjarne Stroustrup介绍了一个声明结构的例子,它带有和不带struct前缀,这让我感到困惑。
I have written a C++ stack application and running it using CYGWIN g++ compiler. The application crashes as exception is not handled perfectly. It gives me stacktrace dump as a file Stack.exe.stackdump. I am new to this StackTrace thing could some one tell me how to read it and what does it signify? Just to make clear based on received comments, The stack data structure is just an example t
我编写了一个C ++堆栈应用程序并使用CYGWIN g ++编译器运行它。 应用程序崩溃,因为异常处理不完美。 它给我stacktrace转储为一个文件Stack.exe.stackdump。 我对这个StackTrace不熟悉,可能有人告诉我如何阅读它,它意味着什么? 只是为了根据收到的评论清楚地说明,堆栈数据结构仅仅是一个让应用程序崩溃并给出stackTrace的例子。 我的意思是这个堆栈跟踪是在程序崩溃并且与我的堆栈数据结构应用程序无关的任何情况下生
I am working with 3D volumetric images, possibly (256x256x256). I have 3 such volumes that I want to read in and operate on. Presently, each volume is stored as a text file of numbers which I read in using ifstream. I save it as a matrix(This is a class I have written by dynamic allocation of a 3D array). Then I perform operations on these 3 matrices, addition, multiplication and even fourier
我正在处理3D立体图像,可能(256x256x256)。 我有3个这样的卷,我想阅读和操作。 目前,每卷都被存储为一个我使用ifstream读取的数字文本文件。 我将它保存为矩阵(这是我通过动态分配3D数组写入的类)。 然后我对这三个矩阵进行运算,加法运算,乘法运算甚至傅立叶变换。 到目前为止,一切运行良好,但是,它需要很多时间,特别是傅里叶变换,因为它有6个嵌套循环。 我想知道我如何加快这一点。 此外,我是否已将图像
This is from memory, so I could be misusing a few words, but the meaning should be understandable I'm currently at University, doing a BIT majoring in programming - We started C++, and when we started using arrays, our C++ teacher (a teacher with strange ideas and programming rules, such as no comments whatsoever allowed) told us that we should make our array sizes in multiples of 4 to be m
这是来自记忆,所以我可能会滥用几句话,但意义应该是可以理解的 我现在在大学,在编程方面做了一个BIT专业 - 我们开始使用C ++,当我们开始使用数组时,我们的C ++老师(一个有着奇怪想法和编程规则的老师,比如没有任何评论允许)告诉我们,我们应该使我们的数组大小为4的倍数更高效: char exampleArrayChar[ 4 ]; //Allowed float exampleArrayChar[ 6 ]; //NOT Allowed int exampleArrayChar[ 8 ]; //Allowed 他说这背
I wrote two Matrix Multiplications programs in C++: Regular MM (source), and Strassen's MM (source), both of which operate on square matrices of sizes 2^kx 2^k(in other words, square matrices of even size). Results are just terrible. For 1024 x 1024 matrix, Regular MM takes 46.381 sec , while Strassen's MM takes 1484.303 sec ( 25 minutes !!!!). I attempted to keep the code as simple
我用C ++编写了两个矩阵乘法程序:普通MM(源程序)和Strassen的MM程序(源程序),它们都在大小为2 ^ kx 2 ^ k的矩阵上运作(换句话说,即大小均匀的矩阵)。 结果非常糟糕。 对于1024 x 1024矩阵,普通MM需要46.381 sec ,而斯特拉森的MM需要1484.303 sec ( 25 minutes !!!!)。 我试图尽可能简化代码。 网上发现的其他Strassen的MM例子与我的代码没有多大区别。 斯特拉森的代码的一个问题很明显 - 我没有切入点,切换
I am taking a look at large matrix multiplication and ran the following experiment to form a baseline test: Randomly generate two 4096x4096 matrixes X, Y from std normal (0 mean, 1 stddev). Z = X*Y Sum elements of Z (to make sure they are accessed) and output. Here is the naïve C++ implementatation: #include <iostream> #include <algorithm> using namespace std; int main() {
我正在研究大矩阵乘法,并进行以下实验以形成基线测试: 从std normal(0 mean,1 stddev)中随机生成两个4096x4096矩阵X,Y。 Z = X * Y Z的总和元素(以确保它们被访问)和输出。 以下是天真的C ++实现: #include <iostream> #include <algorithm> using namespace std; int main() { constexpr size_t dim = 4096; float* x = new float[dim*dim]; float* y = new float[dim*dim]; f
I have been looking at memory allocation lately and I am a bit confused about the basics. I haven't been able to wrap my head around the simple stuff. What does it mean to allocate memory? What happens? I would appreciated answers to any of these questions: Where is the "memory" that is being allocated? What is this "memory"? Space in an array? Or something else?
我最近一直在研究内存分配问题,我对基础知识有点困惑。 我一直无法围绕简单的东西包扎头脑。 分配内存意味着什么? 怎么了? 我会很高兴回答以下任何问题: 正在分配的“记忆”在哪里? 这是什么“记忆”? 数组中的空间? 或者是其他东西? 这个“内存”被分配时究竟发生了什么? 当内存被释放时究竟发生了什么? 如果有人能够回答这些C ++代码中malloc的含义,它也会帮助我: char* x; x = (char*) malloc (8);