Questions tagged [gcc]

GCC is the GNU Compiler Collection. It's the de facto standard C compiler on Linux and supports many other languages and platforms as well.

Filter by
Sorted by
Tagged with
1
vote
0answers
22 views

CMPLX Yields Undefined Symbol with GCC

I'm trying to hunt down a problem using complex literals when compiling with GCC. Consider the following #include <stdio.h> #include <complex.h> int main(void) { double complex z = ...
0
votes
1answer
17 views

One or two weird linking errors with some inline assembly

I have the following short application (The original is taken from: https://www.aldeid.com/wiki/X86-assembly/Instructions/str) I just modified it (tried to...) to make it compilable on linux too. #...
0
votes
0answers
23 views

Eclipse Artifact name variable while build steps

In eclipse I can use in C/Cpp Build->Setting ->Build artifact->Artifact name to configure the name of the binary that export in build. When I want to use this Artifact name as a variable ...
0
votes
3answers
72 views

Will compiler create vtable irrespective of object creation in c++

class B { public: virtual void fun1() {} }; class D: public B { public: virtual void fun1() {} }; int main() { //Empty Main. //Not creating any object of B or D. return 0; } In ...
2
votes
0answers
32 views

GCC constexpr allows add but not bitwise-or with address

Consider this code: #include <cstdint> static int x = 0; const uintptr_t arithmetic() { static constexpr uintptr_t result = ((uintptr_t)&x) + 1u; return result; } const uintptr_t ...
0
votes
0answers
15 views

f2py linking quadmath libraries?

I have spent the last three days trying to use f2py to interface fortran to python. I am working on windows using both cygwin and mingw. This post is about using cygwin, but I'm concerned about ...
0
votes
0answers
15 views

C++ Boost undefined reference to `boost::filesystem::path::m_normalize()'

I am trying to compile a program called UKB (https://github.com/asoroa/ukb), but I am facing problems in compilation that I cannot solve: When I execute make it returns g++ -c -O2 -Wall -Wno-...
1
vote
0answers
42 views

Inserting “marker” instructions into assembly without GCC reordering them

For purposes of doing performance analysis it is useful to be able to tell which line of C code goes with which line of generated assembly code. This can be very difficult once a sufficient number of ...
0
votes
0answers
8 views

Debugging C in VS Code on Linux Mint does not work

I want to debug a C program. By clicking on "Add Configuration..." or clicking the Settings-Button, nothing happens. I recognized that the text "Activating extensions..." appears at the status bar. I ...
0
votes
0answers
40 views

How to force GCC to generate specific floating-point instructions [duplicate]

Given the following C code, double a = 4.00; double b = 123.456789; double c = 15.123; double res = a*b + c; return res; compiling with riscv64-linux-gcc -g -o2 generates the ...
0
votes
1answer
24 views

Translate from cc command line to CMakeLists.txt [duplicate]

I want to use cmake on my project but I have to define a preprocessor macro this way : #if defined CONFIG_TEXTUI void BoardView_init (void) { } void BoardView_free (void) { } void ...
-2
votes
0answers
21 views

How to pass arguments to inline GCC/Clang assembly with Intel syntax? [duplicate]

How do I re-write this using Intel syntax? int main() { int e; asm( "movl $5, %0" : "=a" (e) ); printf("%d\n", e); return 0; } I tried this with -masm=intel, and it doesn't work, ...
5
votes
0answers
46 views

Address of templated inline constexpr variable is not treated as constant expression by gcc?

template <typename T> inline constexpr int a = 1; static_assert(&a<void>, ""); This does not compile on gcc 9.2, but compiles on both clang and msvc. Gcc complains that the ...
-1
votes
0answers
19 views

Binary Bomb phase 4 help (Reverse engineering) [duplicate]

Good day. I'm struggling with phase 4 of the binary bomb. I have googled and saw a few questions regarding this phase. However, it is not the same as those on the internet. The phase still, as the ...
4
votes
0answers
50 views

Why GCC -Ofast makes the program wrong but only when it prints the result twice?

Recompiling an old program made it output the wrong result. I'd like to know why. I know that -Ofast may "disregard strict standards compliance" but I'm curious about what happens under the hood. I ...
2
votes
1answer
43 views

Best practices regarding warning outputs when compiling in gcc?

I'm learning c and am compiling all my programs using gcc in linux subsystem for windows. I learned that I can include some flags by the gcc standards. Some include the basic -o or -lm. I discovered ...
0
votes
1answer
36 views

Program cannot load shared libary GCC

First things first, here is the error message: ./Game: error while loading shared libraries: libEngine.so: cannot open shared object file: No such file or directory There was no problems while ...
0
votes
0answers
8 views

macOS : Brew-installed gcc throws link errors (ld: symbol(s) not found for architecture x86_64) when compiling a SFML-based Pong game

I'm trying to compile a Pong game written by a friend using the SFML (https://www.sfml-dev.org/) graphics library. It works out of the box on Ubuntu, to make it run on macOS I've installed SFML via ...
0
votes
1answer
47 views

How to pass arguments to inline GCC/Clang asembly with Intel syntax? [duplicate]

All documentation uses AT&T syntax. int EAX; asm( "movl $5, %0" : "=a" (EAX) ); How do I re-write this using Intel syntax? int EAX; asm( ".intel_syntax noprefix;" "mov %0, 5" :"=a"(EAX) )...
0
votes
0answers
16 views

GCC compile error for templated class method [duplicate]

I would like help understanding this gcc compilation error. The following c++ code is for what I thought was a relatively simple class which will hold some data and use a metadata class (which will ...
2
votes
1answer
44 views

GCC error when typedef name coincides with variadic template parameter name

I stumbled on a strange interaction between typedef and variadic template parameters that I'd like to understand. The following code compiles with clang but gives an error with GCC: template<...
0
votes
1answer
13 views

Python3, gcc and clang on MacOS

I am trying to make a Python script on my Mac (MacOS 10.14.6 Mojave) and I am getting trouble with installing a module (watchdog). I have the built-in Python 2 and I installed Python 3 with Homebrew. ...
0
votes
2answers
57 views

Is there any way to make a function smartly in C such that it performs different functions in different values of arguments?

😄 I have to create 2 structs namely rectangle and oval, where the rectangle structure contains its length and breadth and the oval structure contains the lengths of its semi-minor and semi-major ...
-1
votes
0answers
22 views

Why is an extra “../” getting added to ld search path on my system?

#include <iostream> using namespace std; int main() { cout << "Hello\n"; return 0; } If I compile the program above on my Ubuntu 18.04 system, $ g++ hello.cpp -o hello /usr/bin/...
0
votes
0answers
44 views

How does GCC align struct in x64?

TL;DR When aligning the stack to multiple of 16 bytes, why are the paddings at the higher address for struct while at the lower address for primitive types? More details First of all, my machine ...
0
votes
0answers
5 views

How do I get gcc to print localized error messages? (WSL - Ubuntu 16.04)

I figure I'm just missing one step, but no matter what I try, I can't get localized error messages from gcc. And most searches I've tried turn up people trying to disable the messages and use English. ...
-2
votes
2answers
38 views

Why I have a wrong result in C after storing a division of integers in a floating variable? [duplicate]

I am working with STM32 and GCC Compiler and I make the following division: uint8_t w, h; w=2; h=5; float test = (w * h) / 8; and the result is test=1 Why am I wrong? I cannot understand this ...
0
votes
0answers
28 views

external/local_config_mlir/include/mlir/IR/Attributes.h:783:20: internal compiler error: in assign_temp, at function.c:968

I am trying to build Tensorflow 2.0 on Ubuntu 16.04LTS I get the error with gcc 4.8, gcc 5, gcc 9.2, etc. Here are the version of bazel and gcc: ai) [email protected]:~/tensorflow$ bazel --version ...
0
votes
0answers
49 views

Reverse engineering assembly

Good day. I am struggling to figure out what the following assembly code does. The code is from objdump. To give it some background, a random "string" is generated (for example "68 7"). Before all ...
0
votes
0answers
39 views

C++ incorrect constructor order in gcc compiling static members in generic class

The constructor order problem I have probably faced a bug in gcc compiler when I was solving a problem of making an arbitrary trait of a class like ThorsSerializer does, but more generic. Moreover I ...
2
votes
1answer
75 views

Throwing bad_exception when calling current_exception()

Link https://en.cppreference.com/w/cpp/error/current_exception provides the following description of current_exception(): If called during exception handling (typically, in a catch clause), ...
0
votes
0answers
27 views

gcc: use and practical meaning of preprocessor output flags 3 and 4

While looking at gcc preprocessor output on a file #include-ing a system header, I noticed that linemarkers contained flags 3, or 4, respectively (I found it the definition here: [1]): 3 This ...
5
votes
4answers
94 views

Compiler independent class name

I need to print the name of a class such as template<typename... Args> struct S{}; Using typeid(S<int,std::vector<double>>).name() its fairly simple to print something ...
4
votes
0answers
44 views

How to force the compiler to pass a “vector of 4” wrapper class as single XMM register?

I'm trying to optimize a small "vector of 4 floats" wrapper class, and of course I want to make it convenient as well. For example: typedef float v4f __attribute__ ((vector_size (16))); struct V4 { ...
1
vote
1answer
45 views

Why does STL function use node's color to calculate std::map node predecessor

I was looking through libstdc++'s implementation of std::map and noticed that iterator increment and decrement functions are not entirely symmetrical. local_Rb_tree_decrement function (aka predecessor)...
0
votes
0answers
23 views

On x64 In mutli thread scenario, can each member, of size byte or word, of a structure be set locklessly without affecting the other members [duplicate]

struct test { char hit char delete spinlock_t lock } setting test.hit = 1 without lock . If multiple threads write it, is there a chance that 'delete' field is overwritten? i.e. while ...
0
votes
1answer
38 views

Pre-increment operator with and without pointer in C [duplicate]

I am running gcc 7.4.0 on ubuntu 18.04. I compiled and ran the following code #include<stdio.h> int main() { int *p; int a[2]; a[0] = 100; a[1] = 200; p = a; int b = 10; printf("%...
0
votes
1answer
45 views

non-const lvalue reference type _normal_iterator<> cannot bind a temporary of type _normal iterator in gcc

In the last line of the below code I get an error: non-const lvalue reference type _normal_iterator<> cannot bind a temporary of type _normal iterator with gcc, but not with Visual studio. Any ...
0
votes
0answers
20 views

VSCode including header file in c

I'm trying to work with my header files in c. When i use code blocks, it handles the header include part, but in vs code, i couldn't figure it out yet. this is what i get in vs code. The files are in ...
0
votes
1answer
25 views

Shared library name in executable is different than the filename

A cleaned up version of my compile command looks like gcc -o semantic_seg -Wl,-rpath,... -l:libnvrtc-5e8a26c9.so.10.1 ... and I have a dynamic library file named exactly libnvrtc-5e8a26c9.so.10.1 in ...
1
vote
0answers
26 views

Why does address sanitizer overlook seg faults sometimes?

Been using fsanitize=address while compiling C programs, in order to track seg faults for about a year now. Every now and then I encounter a strange behavior, my program would be seg faulting if ...
0
votes
0answers
53 views

GCC -H option issue (header dependency tree listing)

GCC can display all header dependencies of a .cpp file in a tree structure if the -H option is passed. It's a very handy feature because 1) it produces the output after/while evaluating the defines ...
0
votes
1answer
57 views

bytes value of 8 bytes or 16 bytes number

I assume every byte should be valued 0 if a long var is initialized to 0. (same for __int128) This is a piece of testing code: int64_t i64 = { 0 }; auto addr = &i64; LOG(INFO) <&...
0
votes
1answer
51 views

Is there a way to port “best type” floating-point constants from a micro to another?

In my specific case, I firstly developed a program to run in a Texas Instruments microcontroller (TMS320F28335). It was a real time synchronous generator simulator so it needed to perform an important ...
0
votes
0answers
8 views

Declare a symbol's type in ldscript

I want to declare the type (specifically STT_FUNC) of a symbol that I declared in my ldscript. Is such thing possible, and if it is then how? For example, I have the following: funcy = 0x11223344; ...
0
votes
1answer
29 views

How to install an older version of gcc on Fedora

I tried to install CUDA on fedora 31 but got stuck at the last step because CUDA officially support fedora 29 (gcc 8.2) while the version shipped with fedora 31 is 9.2, I then installed pytorch with ...
10
votes
2answers
119 views

Mismatched deduction of auto types between different c++ compilers

So, I am trying to implement the dot product (https://en.wikipedia.org/wiki/Dot_product) in some flavour of modern C++ and came up with the following code: #include <iostream> template<...
0
votes
0answers
23 views

GCC Stack overflow by negative number

I'm getting a very strange error msg. A negative Flash overflow. How is this possible I'm calling a debug function to print out error msgs on multiple occasions. This error logger function looks like ...
0
votes
0answers
10 views

Errors with libexa when compiling xorg-server

I am trying to compile the xorg-server version 1.20.5. LDFLAGS="-lrt" ./configure \ --prefix=/usr \ --enable-glamor \ --enable-config-udev \ --enable-config-udev-kms \ --enable-suid-wrapper ...
0
votes
2answers
35 views

CMake passes all gcc flags to nvcc as well

My project uses cuda kernel for a small module and needs nvcc for compiling. During compilation, cmake pass the same linker and compiler flags intended for gcc to nvcc as well. In my particular case, ...