Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
1 answer
75 views

Use flex to parse ":" and ".:" in expressions

I have a lex file, and based on the original, I would like to add support for recognizing (.:). My modifications are as follows: %option caseless ALP [a-z]+ NUM [0-9]+ REF {ALP}{NUM} ...
lijiang99's user avatar
0 votes
1 answer
87 views

How can I elegantly put a big constant matrix without it being basically unreadable?

I'm writing a compiler project for school and I need to put a table of precalculated values into my code. The problem is that it is unreadable. How should I approach this problem? So far I'm doing it ...
Matyáš Ott's user avatar
2 votes
2 answers
114 views

Translation limits of an identifier in C

I have started to write my own C compiler for the purpose of education. My goal is to be mostly C99 standard conform. Now I have a question about the maximum length of an identifier. This is an ...
Johannes Krottmayer's user avatar
2 votes
1 answer
113 views

What is the exact compiler optimization applied here expect for tail recursion elimination?

I'm compiling a simple C program, implementing an inorder tree traversal function: void inorderTraversal(struct TreeNode* root) { if (root == NULL) { return; } inorderTraversal(...
Fish Toucher's user avatar
61 votes
5 answers
7k views

Can you find a real example of "time travel" caused by undefined behaviour?

I am curious. Does anyone know a non-hypothetical C or C++ counterexample to the myth that "the impact of the undefined behaviour is limited to code which runs after the line with undefined ...
Andrey Bienkowski's user avatar
0 votes
1 answer
63 views

Invalid initializer error with anonymous structs

I have this code here: Void() aba () { } #define std_Dynamic_Array(T) struct{Int32() count; Int32() capacity; T* memory; } Void() no_body_func (Int32() b); Int32() test_func (Int32()*** a) { } Int32() ...
kamkow1's user avatar
  • 501
0 votes
3 answers
144 views

When inlining a C function, can an optimizing compiler dereference a pointer more times than explicitly written in the source code?

Consider the following code: int y = 1; int* p = &y; inline int f(int x) { return x + x; } int g(void) { return f(*p); } In this code, there is one explicit dereference. Is a C compiler ...
john smith's user avatar
-1 votes
1 answer
60 views

flex and bison behave unexpectedly towards my input

I was trying to write a logical expression evaluation tool with flex and bison. I've gone over the code many times but when I run the executable it just ignores my input and prints Syntax error after ...
Overstacked's user avatar
1 vote
1 answer
134 views

What is the reasoning behind this boilerplate start-up code?

Here's a snippet from disassembled output of a simple program with gcc on Linux: 400478: ff 15 6a 0b 20 00 callq *0x200b6a(%rip) # 600fe8 <__libc_start_main@GLIBC_2.2.5> ...
user129393192's user avatar
1 vote
0 answers
58 views

Unknown type name ‘Node’ in the parser file. (Yacc program)

I've been working on a Yacc program (parser.y) to develop a small compiler that handles arithmetic operations. I'm using Yacc (Bison) and Lex tools to generate the parser and lexical analyzer, ...
Don R's user avatar
  • 41
-3 votes
1 answer
190 views

What is the proper way to retrieve error handling from a compiler to an ide? [closed]

I have written my own programming language and have finished the self hosting compiler for it. I am now writing the ide frontend in windows for this compiler backend. The issue is I created all the ...
raven_lee's user avatar
-3 votes
3 answers
129 views

How does does compiler know the definition of pre defined function even before linker haven't linked object file and library file?

We know that definition of pre defined functions are in library files, and it is the job of linker to link that library code(which is already compiled) to our object file (which has been created after ...
Harsh Chaudhary's user avatar
2 votes
0 answers
77 views

Load function written in amd64 assembly into memory and call it

I am trying to write a small jit compiler. For that, I need to somehow load new code into memory and then execute it. Given the output of the compiler for a function that simply adds the 2nd and 3rd ...
lorenzw's user avatar
  • 396
2 votes
0 answers
137 views

Write a gcc plugin that inserts macros at the beginning of each function

I understand that I can use __cyg_profile_func_enter and -finstrument-functions to insert code, but is it possible to insert macros by writing a gcc plugin? Is there any documentation or possibly an ...
Coloda's user avatar
  • 39
3 votes
1 answer
519 views

Can I use a different C standard library without re-compiling the compiler?

I just read this about C standard library: When compiling C code, the C standard library cannot be switched per-compilation. It is necessary to build the entire compiler toolchain for the selected C ...
Yizhe's user avatar
  • 235

15 30 50 per page
1
2 3 4 5
56