Questions tagged [compiler]

A compiler is a computer program that transforms source code written in one programming language into another computer language.

Filter by
Sorted by
Tagged with
21
votes
7answers
3k views

Detect manual changes to an autogenerated C header

I have a C header that is generated from a CSV file and a python script. The C header mainly contains a list of #define constants. I want to be able to detect manual changes to this header during ...
0
votes
0answers
25 views

Optimizing Phi Instruction Placement after changes in CFG

I am unable to find an algorithm for optimizing or eliminating Phi instructions after some Control Flow Graph modifications. I have found algorithms for destructing and constructing the SSA form, and ...
7
votes
3answers
342 views

code generation - would C be a good compiler backend?

In this and this stack overflow questions, the answers state that C as a compiler backend is a bad idea. But why? C has many compilers that can heavily optimize it. Every platform has a compiler ...
-3
votes
3answers
158 views

Convince a manager to use newer compiler version [closed]

I'm working in some environment where an older version of g++ is used to compile some production code: g++ 4.3.x . This might sound outrageous to you, but in various organizational settings ...
3
votes
3answers
214 views

How to compile to multiple target languages

Sidenote, just learned about Haxe which may offer some insight into this question. The basis of my question is what sorts of tradeoffs (if any) need to or must be made if you wanted to compile one ...
8
votes
3answers
630 views

How can we avoid showing the literal path in the exception's stack trace?

When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C:\users\DEVELOPER_FULL_NAME\path\some-module.cs. So it ...
2
votes
4answers
213 views

Ahead-of-time compilation to native machine code of dynamically typed languages

It is my understanding that: It's particularly difficult to compile ahead of time, to efficient native machine code, a dynamically typed language like Python. Largely as a result of the above, the ...
-1
votes
1answer
188 views

Difference between direct and indirect function() calls

I am curious about the Difference between direct and indirect function() calls Could anyone help in the diff analysis ? The c source code could be found at subroutine_direct.c and ...
-4
votes
3answers
280 views

Is it really always easier to write an interpreter than a compiler?

I've read that generally it's easier to write an interpreter than a compiler. If that's true, what's the reason? Writing an interpreter seems to me equivalent in the level of difficulty as writing a ...
0
votes
1answer
112 views

Are parser generators useful for parsing a shell language?

From my understanding, parser generators accept as input some form of context-free grammar description. The context-sensitive features are handled during semantic rather than syntactic analysis (...
-1
votes
1answer
231 views

Do C# compilers optimize away the facade pattern?

In C#, if I hide away implementation behind a facade, or the "pimpl" pattern, does the compiler optimize away the intermediate function call if all it's doing is calling an equivalent method from ...
2
votes
0answers
78 views

Windows: Have a dedicated MS Visual C/C++ toolchain

For a CI system and the developers in our team, I'd like to be able to use a specific version of a MSVC toolchain for native Windows builds. The goal is to have a well-defined consistent build-...
2
votes
0answers
79 views

Is it dangerous to link together -mno-red-zone and regular code?

I know that in x86_64, there exists a 128 byte red zone above (or below, address-wise) the stack pointer that functions can use without subtracting from rsp. This sounds to me like the only things ...
2
votes
3answers
252 views

Is a literal out of range a syntax error or a semantic error?

I am reading more about the differences between syntax and semantics, but I am still wondering about this one. Let's assume that we have a language that only allows integers to be in the range of 0-...
0
votes
1answer
106 views

How to design a system that can operate and replay its functions call stack?

I am writing a processor for the Citation Style Language (CSL) in JavaScript. Before I explain what my problem is, I must give some context first: CSL is an XML specification for describing how to ...
1
vote
1answer
136 views

Switching out implementation source files in C project

For simplicity, let's say I have the following C project structure: src/ utils/ logger.c logger.h main.c secondary_component.c main.c starts with: #include "utils/logger.h" I would ...
0
votes
1answer
168 views

Why do new language versions typically use an early compiler version for the bootstrap compiler?

Wikipedia describes a bootstrap compiler to have these properties: An initial core version of the compiler A minimal subset of the language to be used by successive compiler versions Everything I've ...
0
votes
1answer
72 views

How is a function in execute only space compiled?

I don't quite understand, how the following typedef is parsed by a compiler to call code at a specific address. I guess I understand that a function is just a pointer and we're typedefing such a ...
2
votes
1answer
127 views

C++ design pattern for template instantiation based on run time information?

Say I want to be able to create objects for a range of template parameter template<int a> class Myclass : public MyclassSuper{...}; And I want to create objects like Myclass<...
3
votes
2answers
310 views

What are the bottlenecks for the Java build speed?

Which underlying system parameters have most influence on how fast a typical Java project (say dozens of classes and dependencies) builds? There is a lot information on JIT (bytecode to CPU ...
3
votes
2answers
1k views

What is the difference between a static library and an archive library?

In the comments of a recent answer, I equated a static library with an archive of compiled object files. The response was that they are not the same, so what is the difference? To clarify - gcc ...
1
vote
1answer
160 views

How function parameters are compiled in JavaScript

I am trying to understand how functions -- which could have dozens of parameters that could themselves be functions or complex objects (I'm thinking JavaScript) -- get passed the arguments when ...
0
votes
3answers
109 views

Resolving function calls as function arguments using a stack

After doing a bit of reading, I have a vague understanding of the use of a stack in calling functions when one function calls another, where the arguments are placed on the stack for the called ...
-1
votes
2answers
181 views

Relationship between the C standard libraries and Java standard libraries

Which is the relationship between the standard libraries of C language and the standard libraries of other software platforms, e.g. Java, .NET, Python? Do the Java (.NET and Python) standard libraries ...
4
votes
2answers
354 views

How can one interpret an Abstract Syntax Tree without recursion?

I am busy building an interpreter for a Rebol-like language. I have previously built a Lisp interpreter where I used recursion, but now I just want to use a stack and not rely on the recursion ...
3
votes
3answers
925 views

How does a compiler work when it's not directly compiling to machine code

I know the compilation process goes with this flow: source -> parse -> AST -> intermediate code -> assembly -> machine code and in the case of Java you will have bytecode which is ...
-1
votes
1answer
198 views

What happens when loops are compiled or interpreted?

I have came across a concept in recursion which says that when loops are compiled or interpreted then they get converted to recursive functions. If it is true how it takes place ?
2
votes
3answers
284 views

In c++, is there a way inside a function block, to execute cleanup code after the value has been returned?

Backstory (You can skip) I am building an API for managing Files and Directories in a consistent manner across a project. This is for deduplication and consistency when performing a task, and in this ...
0
votes
4answers
262 views

Is it better to use the linker to compile multiple C++ files or better to include them as a header file

Assume we have two files a.cc #include <iostream> int timesTwo(int in); int main(){ std::cout << timesTwo(5) << std::endl; return 0; } b.cc int timesTwo(int in){ return in*2;...
2
votes
3answers
637 views

GCC or Clang to output bytecode for a VM?

Long story short, I wanted to use C as a scripting language and in a portable manner so I created a register-based, JITless VM to accomplish this. I've formalized the VM's ISA, script file format, ...
0
votes
0answers
72 views

Results of testing different compiler optimizations of GNU GCC are confusing

I tested out a few different compiler optimizations on GNU GCC, in the CodeBlocks IDE. With each different optimization I ran the same test: I let my program try to build as big of a tree as it could ...
0
votes
1answer
113 views

Is there a way to use and ignore blocks of code, caused by events during runtime?

I'm working in C++14 and trying to figure out a way to put two classes (with the same name) inside the same header file. In this scenario one class would always be ignored as a result of something ...
4
votes
3answers
484 views

How to optimize a mixed stack/register bytecode with control flow and side effects?

I'm trying to figure out a technique to optimize bytecode for the following virtual machine: Bytecode is a flat list of instructions, with execution starting from the first instruction. Stack ...
0
votes
4answers
393 views

Should my lexer allow what is obviously a syntax error?

This is kinda like a concrete version of the question Coming up with tokens for a lexer. I'm writing a lexer for a small subset of HTML. I'm wondering what should I do when the input stream ends and ...
-5
votes
1answer
115 views

LL(K) grammer generation for postfix expressions [closed]

I have a problem in formulating LL(K) grammar for this postfix expression problem, given (4 3 / 2 * 4 5 / +) as an input must output 52/12
5
votes
3answers
394 views

Does the output of a compiler depend on the OS you are using?

In the company I am working in we have a management software, written by an external programmer. Let's call the software PK. PK was initially written in the 90s using C++. Since then it was regularely ...
0
votes
2answers
1k views

Understanding Context Free Grammar using a simple C code

I'm trying to understand the difference between terminal and non-terminal values in a real language. I wasn't able to find enough examples on real language CFGs on the internet, most examples are ...
-2
votes
1answer
138 views

What is the minimum set of operations a language implementation must provide for it to be usable for all applications?

As a fun hobby project, I'm writing a simple bytecode VM and a compiler from a basic high-level language to the said bytecode. (Offtopic: the compiler is inspired by Jack Crenshaw's awesome tutorial -...
-7
votes
1answer
226 views

Why does the C compiler use memory for simple arithmetic operations

Assume the following C code: #include <stdio.h> int main() { int a = 5; int b = 15; return a + b; } Compiling it using gcc creates an assembly code which includes the following: ...
-4
votes
1answer
42 views

Writing an application that calls another application for some tasks: how it works?

I have written a C++ code that calls a solver called CPLEX to solve an integer linear optimization problem (under Ubuntu 18.04). I have three sets of data and I use make command to create 3 ...
3
votes
1answer
583 views

Why am I advised to not inline functions that are called only once?

I understand inlining as the following: A separate function which is marked as "inline" (assuming the compiler really does inline) will be "merged" into the function it is called. i.e. (pseudo code)...
1
vote
1answer
361 views

Is it feasible to write an IR-to-assembly compiler as opposed to an LLVM backend?

I've made a virtual processor with a simple instruction set and memory model as a learning exercise (and mostly just for fun). I can write programs in its assembly language, assemble them with my ...
1
vote
2answers
201 views

How does Gamemaker Create Executables?

How does a Program that is already compiled create standalone .exe files without an apparent compiler? Example game making software like GameMaker that lets you create a game, add all the resources, ...
2
votes
1answer
200 views

What is the difference between writing in assembly vs converting high level language into assembly using compiler?

So i heard that in modern operating systems and device drivers, some parts of them are still written in assembly for better memory optimisation and speed but do developers actually write it in ...
0
votes
2answers
234 views

How can I test generated assembly?

I'm working on a C compiler for Linux for the purpose of personal curiosity/fun. How can I test the generated assembly before the compiler is complete enough to do anything useful? For example, if I ...
0
votes
2answers
261 views

Why don't variables in TypeScript implicitly infer literal typing?

Given a literal type, for instance 1 | 2, assigning a value to a variable that correctly corresponds to the literal type will fail. interface SomeInterface { foo: (1 | 2); } class SomeClass ...
1
vote
1answer
546 views

Would Cython-like “Cypescript” be a feasible idea?

Cython is a superset of Python that can be complied into C modules that can be imported and used normally in Python code. This can be used to speed up parts of a Python program. In a recent project, I ...
1
vote
1answer
531 views

What does the 'emulation' do in the Linker?

I am looking into assembler and I am trying to understand the whole compilation process. During the linking step I use: ld -m elf_i386 -s -o hello hello.o Everything works fine, but I do not ...
1
vote
3answers
422 views

Does the Perfect Compiler trump source differences

Is it theoretically possible to create a perfect compiler for a language (for example C) meaning that if two different persons make two different implementations of the same algorithm then the ...
8
votes
2answers
550 views

Only one number type in language design

I am currently learning about compiler construction and language design and I am thinking about what native datatypes I want to support in my language. Now there is a whole lot of languages that make ...

1 2 3 4 5 9