Questions tagged [gcc]
GCC is the GNU Compiler Collection. It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well.
36,577
questions
0
votes
0answers
26 views
binary function offset issue
I am using the disassembler to find the starting point of the function. However, the obtained address and the offset of the actual file are different.
Are there any compile options to handle this?
I ...
0
votes
1answer
22 views
ternary operator compile error when using gcc but no issue using g++
I have been getting compile issues compiling this code using gcc :
#include <stdio.h>
#include <stdlib.h> /*srand, rand*/
#include <time.h> /*time*/
#include <math.h> /*sqrt*/
...
0
votes
0answers
11 views
GCC binary floating-point conversion under source-gcc/gcc/real.[c\h] test on x86-64
For example: float a = 0.3333
This is real_value information under gcc/real.h.
struct GTY(()) real_value {
/* Use the same underlying type for all bit-fields, so as to make
sure they're packed ...
0
votes
0answers
6 views
/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /node_modules/snappy/build/Release/binding.node)
I am running a loopback4 project inside a docker container which runs on centos 7 version. I have installed gcc inside docker but its still giving below error due to gcc version issue as CXXABI_1.3.9 ...
0
votes
0answers
9 views
Is there a way to modify DWARF format output in .elf file regarding external variabels
We have a third party Software that's picks out information from generated .elf about our global variables which are using DWARF debug info to find it.
Previously we have been using IAR compiler which ...
0
votes
0answers
5 views
Problem with building Linux for the RISC-V target
Hello to all there i'm installing the tools for RISCV:
https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
According the documentation:
https://github.com/riscv/riscv-gnu-...
1
vote
0answers
38 views
gcc -Wpadded is inconsistant
I'd like to know when the size of a struct does not equal the combined size of it's members, in other words, when it is padded. gcc has a warning option to do exactly that, -Wpadded.
From https://gcc....
0
votes
1answer
17 views
install stringi on centos 7 without Internet
I have apparently the common problem to install stringe on a Centos CentOS 7.9 without Internet I have just a remote to Cran. It means I have 'stringi_1.5.3.tar.gz'
After unziping I get:
I get the ...
-1
votes
0answers
25 views
LD Undefined Reference [closed]
I got the error undefined reference to `memset' while linking, it compiled fine. I googled the error but nothing helped. The function has a declaration and I really have no idea what the problem is.
I'...
0
votes
0answers
35 views
GCC diverent result between -O0 and -O2 (in GCC version < 9.x same result)
I have a simple C++ application.
The application makes now sense (I remove very much, to have a simple sample).
I found out:
Application have different behavior between compiling -O0 and -O2 (GCC ...
0
votes
2answers
37 views
type conversion query in C
Why the following code prints the value of a as -25536 instead of -25535. My guess is that to normalise the short value in the short range it should do 40000-32767 = 7233 and then start from the first ...
0
votes
1answer
20 views
GTK header files not found when compiling c code in arch linux
I am attempting to compile code using the <gtk/gtk.h> header file using gcc. Whenever I do so I get the following error:
gtk.c:3:10: fatal error: gtk/gtk.h: No such file or directory
3 | #...
0
votes
1answer
52 views
The largest n-bit integer
I thought that computing the largest n-bit integer would be trivial by using bit-shifts. Specifically, my idea was to set all of the bits to 1, and then shift them to the right:
template <typename ...
1
vote
0answers
18 views
gfortran fails when using dylib [closed]
I am using gcc to experiment with dynamic libraries (dylib) on my MacPro, using gcc 10.2.0 under macOS Big Sur, since I am planning to port on macOS an old Fortran program of mine. After installing ...
1
vote
0answers
44 views
Segmentation fault inline jmp [duplicate]
I was playing with inline assembly, and I've noticed something strange. I've written a program which calls a wrapper function of jmp and executes in loop:
#include <stdint.h>
void asm_jmp(void* ...
0
votes
0answers
18 views
Segmentation fault when running the library but no segmentation without library
I have a C library,
when i try to compile creating that static library everything works fine.
when i create some C files that calls that library everything still works fine.
However when i call a ...
0
votes
0answers
9 views
Problem when trying to link to glfw3.lib using MinGW
I am trying to link statically to a glfw3.lib file but I keep getting this error:
main.o:main.cpp:(.text+0x17): undefined reference to `glfwInit' main.o:main.cpp:(.text+0x56): undefined reference ...
0
votes
0answers
20 views
MinGW on windows gcc compiler to create 64 Bit DLL for a nodejs (ffi-napi)
I am using a sample program from https://www.npmjs.com/package/ffi-napi A Node.js Foreign Function Interface for N-API factorial.c is there a way to compile a sample C(factorial_lib.c) ...
1
vote
0answers
43 views
Why does GCC 10 mfence no more STD Atomic operations? Is it sufficient enough by the memory Model? [duplicate]
I discovered currently that GCC 10 will no more use the mov and mfence method and instead will use the implied lock by an xchg. Is this sufficient by the memory model to not break any stuff when using ...
0
votes
0answers
21 views
VSCode Debugger: breakpoints ignored with C and GDB (-g flag)
When I run the debugger on my C project, the breakpoints I set by clicking next to the lines are ignored. The file runs normal though. Also, I am able to run gdb on the same executable from the ...
0
votes
2answers
61 views
GCC optimalizations ignore for loop condition
so I wrote this code:
#include <iostream>
constexpr
int fibonacci (int n) {
int a = 0;
int b = 1;
for(auto i = 0; i < n; i++) {
b += a;
a = b - a;
}
...
0
votes
2answers
48 views
Why string constant stored in .rodata and the address lie in code section?
Here my simple code is,
{
int a=10;
char *str="jigneshparmar";
printf("address of str data:%p , address of str variable:%p\n",str,&str );
getchar();
return ...
2
votes
1answer
74 views
Invalid operands to binary expression error (missing const) in std::sort: Why does specifying the compare operator solve it?
Considering:
#include <algorithm>
#include <vector>
struct A {
double dummy;
bool operator<(const A& a) { ///Here I am missing a `const`
return dummy < a....
0
votes
0answers
20 views
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-i’
I use this command->
aarch64-linux-gnu-gcc -i ok.c
to see the output of the prepossesses file
But it gives me error->
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-i’
...
0
votes
1answer
71 views
Cortex-M compiler generates improper FOR loop
Tested and reproduced on Cortex-M 4 and Cortex-M 0.
I have discovered an issue with the GCC compiler. When a function is declared as type int (non-void), and contains a for loop, but does not have a ...
0
votes
1answer
15 views
error: ‘aligned’ was not declared in this scope and error: expected ‘)’ before ‘(’
I'm trying to compile bwa-gasal2 and when run into this problem
If you donot see anything below this line then there is nothing to "make"
g++ -c -g -Wall -Wno-unused-function -O2 -msse4.2 -...
1
vote
2answers
33 views
How to display the full error messages in VScode?
I've got a problem that's bothering me for a long time. I use VScode on macOS with standart clang compiller. Almost all error messages produced by the "gcc" are cut, and don't help me at all....
0
votes
1answer
38 views
Assembly , syscall not work as expected. Ubuntu Linux x86_64 , using AT&T syntax
I am testing use of .bss for allocation of a memory area to hold a single number. Then print that number to console. The output is not as expected. I am supposed to get e number (12), but get a ...
1
vote
1answer
80 views
How can I read and store video memory in 8086 using C?
I'm writing a tiny OS for my homework and I want to preserve the contents displayed on shell (Because when I use shell to open another application, the screen will be covered by new contents of it, ...
0
votes
0answers
14 views
Compile single static library for Cortex M3, M4, M23 and M33
I'm currently working on a rather generic communication stack. It gets bytes in on one end, parses the packet and calls a callback.
I want to have this stack in a static library (i.e. libcommstack.a).
...
0
votes
0answers
31 views
“undefined reference to ” in gcc compiler
I've added parson.lib file in CMakelist.txt file. Please help me what should i do to resolve this issue
Below is my sample c program code to read json file to print in console.
#include<stdio.h>
...
0
votes
0answers
26 views
How do cmake configuration and default build task configuration play together in VSCode?
I'm compiling this PCL Library example. For reference, it consists of a simple cpp file that includes some PCL headers and does some basic data manipulation, and a CMakeLists.txt file.
Using the ...
0
votes
1answer
19 views
can't run swig tutorial for python
I have tried to no avail to run swig python tutorial, I have checked many similar questions but none solves my issue, I am using
windows *, 64 bit
SWIG Version 4.0.2
Compiled with i686-w64-mingw32-g++ ...
0
votes
0answers
15 views
Can't compile any c program (/usr/bin/ld: 1: Syntax error: newline unexpected)
I have a serious issue, i can't compile any c program, i get the following error :
/usr/bin/ld: 1: Syntax error: newline unexpected
collect2: ld returned 2 exit status
I have found on the net this ...
0
votes
0answers
10 views
GCC - Value Assignment Signed-Char without Int-Literals
I work with ARM-GCC on a 32bit controller.
When i have signed char dummy = -128 there is no issue, but if i do signed char dummy = 0x80 it assigns 0dec instead of -128dec. Why is this? For the ...
0
votes
0answers
11 views
How to enable newly upgraded gcc properly on CentOs?
I upgraded my CentOs from 4.85 to 7.3.1 by doing:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
Now in my terminal, I can see the new gcc:
$ gcc -...
1
vote
0answers
30 views
Multiple conditions and __builtin_expect
I have the below code in a utility library I use:
#ifndef NO_HINT_BRANCH_PREDICTION
# ifndef LIKELY
# define LIKELY(expr) __builtin_expect(!!(expr),1)
# endif
# ifndef UNLIKELY
# define ...
0
votes
2answers
36 views
Trying to set up a pre-compiled header
fatal error: can't create precompiled header stdc++.h.gch: Permission denied
I'm getting the above error while using the command g++ -std=c++14 stdc++.h on windows powershell in the directory where ...
2
votes
5answers
68 views
Declare a pointer with assigned value
#include <stdio.h>
int main()
{
int *p = 65;
printf("%d\n", *p);
return 0;
}
This throws segmentation fault.
But this:
int main()
{
int *p = 65;
printf("%d\...
0
votes
0answers
5 views
Autovectorization of Character Predicates
Here's a simple C function to check whether or not all of the characters
in a string are in the regex character class [A-Za-z_-]:
int checker(char* restrict src, int len) {
int res = 1;
for(...
0
votes
0answers
29 views
how to make section as only in run time
while creating an image from elf I saw that I can make the image smaller by not loading some section to the image (such that hold uninitialized variables for example).
I need to change the way a ...
0
votes
0answers
26 views
x86-64 gcc doesn't assign a stack frame for local variable [duplicate]
I had some problem when I learned about assembly code.
I use "compiler explorer" that is a website that supporting a lot of compiler.
I made a simple code and compiled it as x86-64 gcc.
<...
1
vote
1answer
88 views
Why does GCC include an “empty” XOR
I have following piece of code:
typedef struct {
int x;
int y;
int z;
int w;
} s32x4;
s32x4
f() {
s32x4 v;
v.x = 0
return v;
}
which ...
0
votes
1answer
43 views
Reading variable with inline assembly
I'm wondering, is there a limitation on reading input variables based on the actual instruction?
I'm trying to read an input variable in inline assembly for a .rept directive to repeat an instruction ...
0
votes
0answers
33 views
How to maintain compatibility between gcc 7 and gcc 9 with -Ofast
I have library which I have compiled on Ubuntu 18.04 using the version of gcc which comes bundled in the build-essential package, gcc 7.5.0.
If I then try to compile an application on Ubuntu 20.04 and ...
0
votes
1answer
37 views
How to enable/disable canary?
How to turn off gcc compiler optimization to enable buffer overflow
I see that a command like gcc vuln.c -o vuln_disable_canary -fno-stack-protector is said to disable canary.
I tried the following ...
0
votes
2answers
62 views
Returning a value from a function with no return [duplicate]
I think I have found a problem with the way functions are handled by the gcc compiler.
I don't know if it's a mistake or a never distraction on something I've let slip over the years.
In practice, by ...
0
votes
0answers
11 views
Spin root cannot find gcc file
Hello i have a problem with starting pml files in spin root.
When i try run .pml file i have a error (after cliced automata View)
If instaled all the files from spinroot . com
Windows 10 64 bit
iSpin ...
0
votes
1answer
30 views
Linux - Feature Test Macros and Dynamic Linking
The C standard library includes a method, strerror_r (https://linux.die.net/man/3/strerror_r).
Depending on the "feature test macros" defined at compilation time, and compiling vs the GNU ...
0
votes
0answers
48 views
cpp type generation by the help of gcc/clang
I am looking for some helper method or compiler plugin to generate new types and extend current ones by checking existing code like below;
input;
struct MyType {
int _integer;
char _char;
}
...