gcc4

What is wrong with this use of offsetof?

社会主义新天地 提交于 2019-12-19 12:24:50
问题 I'm compiling some c++ code in MinGW GCC 4.4.0, and getting warnings with the following form... warning: invalid access to non-static data member '<membername>' of NULL object warning: (perhaps the 'offsetof' macro was used incorrectly) This problem seems familiar - something I've tried to resolve before and failed, I think, but a while ago. The code builds fine in Visual C++, but I haven't built this particular code recently in any other compiler. The problem code is the following template..

How do I install imagemagick with homebrew?

自作多情 提交于 2019-12-18 09:55:20
问题 I'm trying to install Imagemagick on OSX Lion but something is not working as expected. -> brew install imagemagick /usr/local/git/bin/git ==> Cloning https://github.com/adamv/ImageMagick.git Cloning into /Users/klebershimabuku/Library/Caches/Homebrew/imagemagick--git... fatal: https://github.com/adamv/ImageMagick.git/info/refs not found: did you run git update-server-info on the server? Error: Failure while executing: git clone --depth 1 https://github.com/adamv/ImageMagick.git /Users/kleber

C-callback to function template: explicitly instantiate template

依然范特西╮ 提交于 2019-12-17 19:15:45
问题 Premise I’m using a C library (from C++) which provides the following interface: void register_callback(void* f, void* data); void invoke_callback(); Problem Now, I need to register a function template as a callback and this is causing me problems. Consider the following code: template <typename T> void my_callback(void* data) { … } int main() { int ft = 42; register_callback(reinterpret_cast<void*>(&my_callback<int>), &ft); invoke_callback(); } This gives me the following linker error (using

(Not So) Silly Objective-C inheritance problem when using property - GCC Bug?

走远了吗. 提交于 2019-12-17 15:57:28
问题 Update - Many people are insisting I need to declare an iVar for the property. Some are saying not so, as I am using Modern Runtime (64 bit). I can confirm that I have been successfully using @property without iVars for months now. Therefore, I think the 'correct' answer is an explanation as to why on 64bit I suddenly have to explicitly declare the iVar when (and only when) i'm going to access it from a child class. The only one I've seen so far is a possible GCC bug (thanks Yuji). Not so

Why does sqrt() work fine on an int variable if it is not defined for an int?

安稳与你 提交于 2019-12-17 14:45:49
问题 In chapter 3 of Programming: Principles and Practice using C++ (sixth printing), Stroustrup states (p.68): "Note that sqrt() is not defined for an int " . Here is a simple C++ program based on that chapter: #include "std_lib_facilities.h" int main() { int n = 3; cout << "Square root of n == " << sqrt(n) << "\n"; } Given the quote above, I would expect the process of compiling or running this program to fail in some way. To my surprise, compiling it (with g++ (GCC) 4.2.1) and running it

Unable to build openssl in Xcode 4.2.1

瘦欲@ 提交于 2019-12-13 04:14:57
问题 I could build openssl in xcode 3.5.2, but recently I upgraded to Xcode 4.2.1. Now when I try to build in the same old Xcode, I'm getting errors. Make[1]: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2: No such file or directory Cp: libcrypto.a: No such file or directory Cp: libssl.a: No such file or directory Can I have a solution for this? 回答1: I found the solution for XCode 4. You need to change in "Build Phases" the text $PLATFORM_DEVELOPER_BIN_DIR/gcc-4.2 to $PLATFORM

Undefined reference to cmph functions even after installing cpmh library

爷,独闯天下 提交于 2019-12-11 17:14:32
问题 I am using gcc 4.4.3 on ubuntu. I installed cmph library tools 0.9-1 using command sudo apt-get install libcmph-tools Now, when I tried to compile example program vector_adapter_ex1.c , gcc is able to detect cmph.h library in its include file but is showing multiple errors like vector_adapter_ex1.c:(.text+0x93): undefined reference to cmph_io_vector_adapter' vector_adapter_ex1.c:(.text+0xa3): undefined reference to cmph_config_new' vector_adapter_ex1.c:(.text+0xbb): undefined reference to

Linking to stdc++ with CMake and GCC 4.1.2

旧街凉风 提交于 2019-12-11 03:55:50
问题 I am developing a library and need to make sure it compiles with 4.1.2(I know, it brings me no pleasure). So on a Fedora 14 Machine I downloaded, compiled and installed GCC41. Now in CMake I only change the following to variables CMAKE_CXX_COMPILER=/opt/gcc41/bin/c++41 CMAKE_C_COMPILER=/opt/gcc41/bin/gcc41 It compiles fine, but it seems to use the wrong version of the standard library. The error(s) I get look like this: /opt/gcc41/bin/c++41 -Wall -Wold-style-cast -Wsign-compare -Wnon-virtual

gfortran multiple definition of main

一世执手 提交于 2019-12-10 17:54:23
问题 I'm having trouble with compiling a piece of code I have been given for my research. It consists of one component written in C++ and the other in FORTRAN. I think the problem is to do with my gcc version. The first file for example is a C++ file (foo.ccp) #include <iostream> using namespace std; extern "C" { extern int MAIN__(); } int main(){ cout << "main in C++\n"; return MAIN__(); } The second is bar.f90: program test implicit none print*, 'MAIN in FORTRAN' end program test I'm trying to

No useful and reliable way to detect integer overflow in C/C++?

邮差的信 提交于 2019-12-09 05:22:04
问题 No, this is not a duplicate of How to detect integer overflow?. The issue is the same but the question is different. The gcc compiler can optimize away an overflow check (with -O2), for example: int a, b; b = abs(a); // will overflow if a = 0x80000000 if (b < 0) printf("overflow"); // optimized away The gcc people argue that this is not a bug. Overflow is undefined behavior, according to the C standard, which allows the compiler to do anything . Apparently, anything includes assuming that