compilation

Is there a standard way to determine at compile-time if system is 32 or 64 bit?

断了今生、忘了曾经 提交于 2019-12-10 12:57:58
问题 I need to set #ifdef - checks for conditional compile. I want to automate the process but cannot specify the target OS/machine. Is there some way that the pre-compiler can resolve whether it it is running on 32-bit or 64-bit? (Explanation) I need to define a type that is 64 bits in size. On 64bit OS it is a long, on most others it is a long long. I found this answer - is this the correct way to go? [edit] a handy reference for compiler macros 回答1: The only compile check you can do reliably

Mvn compile before exec

时光毁灭记忆、已成空白 提交于 2019-12-10 12:34:05
问题 I am trying to set up my POM such that when I do mvn exec:exec or mvn exec:java it will first compile the source and iff successful, execute it. I have the following and have tried moving the <execution> part about but can't get it to work: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> <executions> <execution> <phase>exec<

gcc -Wshadow is too strict?

时间秒杀一切 提交于 2019-12-10 12:29:54
问题 In the following example: class A { public: int len(); void setLen(int len) { len_ = len; } // warning at this line private: int len_; }; gcc with -Wshadow issue a warning: main.cpp:4: warning: declaration of `len' shadows a member of `this' function len and integer len are of different type. Why the warning? Update I see there's a wide consensus of what "shadow" means. And from a formal point of view, the compiler does exactly what it's meant to do. However IMHO, the flag is not practical.

compile vlc android error

谁都会走 提交于 2019-12-10 12:17:38
问题 When I try to compile vlc android project, I got a issue: cd speex-git && patch -fp1) < ../../contrib/src/speex/no-ogg.patch patching file configure.ac Hunk #1 succeeded at 109 with fuzz 1 (offset -3 lines). patching file libspeex/Makefile.am Hunk #1 FAILED at 11. 1 out of 1 hunk FAILED -- saving rejects to file libspeex/Makefile.am.rej patching file src/Makefile.am Hunk #1 FAILED at 11. Hunk #2 FAILED at 24. 2 out of 2 hunks FAILED -- saving rejects to file src/Makefile.am.rej make: ***

C++ conversion from int to bool

丶灬走出姿态 提交于 2019-12-10 11:41:29
问题 I want to know if the compiled code of a bool-to-int conversion contains a branch (jump) operation. For example, given void func(bool b) and int i : Is the compiled code of calling func(i) equivalent to the compiled code of func(i? 1:0) ? Or is there a more elaborate way for the compiler to perform this without the branch operation? Update: In other words, what code does the compiler generate in order to push 1 or 0 into the stack before jumping to the address of the function? I assume that

How does clang manage to compile this code with undefined behavior into this machine code?

元气小坏坏 提交于 2019-12-10 11:32:01
问题 It's a variation of code from this tweet, just shorter one and not causing any damage to noobs. We have this code: typedef int (*Function)(); static Function DoSmth; static int Return7() { return 7; } void NeverCalled() { DoSmth = Return7; } int main() { return DoSmth(); } You see that NeverCalled() is never called in the code, don't you? Here's what Compiler Explorer shows when clang 3.8 is selected with -Os -std=c++11 -Wall Code emitted is: NeverCalled(): retq main: movl $7, %eax retq as if

Create folder inside debug or release con console application

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:29:01
问题 i have a console application in vs2010 (C#) and in the project, i have a Folder added by me (right click on project.. add->folder) and i want that when i compile the application (debug or release), then the folder will be created (if not exists) in the debug or release directory. Is that possible? The console application is a daemon that access to a database and send emails with templates allocated in that folder. I hope you can help me. Thanks! 回答1: There's no "automatic" way to get VS to

Code::Blocks C++ compiling with MacOS Mojave : fatal error: sys/cdefs.h: No such file or directory

社会主义新天地 提交于 2019-12-10 11:24:29
问题 (This is my first question ever on StackOverflow) I have to use a Mac at work, and I'm coding in C++ with Code::Blocks (because I am used to this IDE). 2 days ago I upgraded from MacOS High Sierra to MacOS Mojave and I can fairly say that... it was a bad decision. Now, when trying to #include <math.h> I get this error : fatal error: sys/cdefs.h: No such file or directory . I have tried to reinstall the xcode line command tools with xcode-select --install , but it still doesn't work. Does

USB Driver Compilation Error

拈花ヽ惹草 提交于 2019-12-10 11:18:05
问题 I'm currently trying to compile a Linux USB UART driver, which is provided here: http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21v1410 The driver consists of 2 header files and one large C file. These are the contents of the Makefile: obj-m := vizzini.o KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) EXTRA_CFLAGS := -DDEBUG=0 all: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install clean: rm -rf *

Do comments get translated to machine code? C++

▼魔方 西西 提交于 2019-12-10 10:59:13
问题 When a program written in C++ has comments, are those comments translated into machine language or do they never get that far? If I write a C++ program with an entire book amount of comments between two commands, will my program take longer to compile or run any slower? 回答1: Comments are normally stripped out during preprocessing, so the compiler itself never sees them at all. They can (and normally do) slow compilation a little though--the preprocessor has to read through the entire comment