Questions tagged [compilation-time]
40 questions
4
votes
4 answers
How to parse a static const std::string in compilation time?
I have some SQL queries with binds in my C++ code, those queries are static const std::string, because those queries are complex it is very easy to be wrong with some details. I would like to do some very basic checks in compilation time, for…

Mauricio Ruiz
- 322
- 2
- 10
4
votes
1 answer
How can I check if a library is available before compiling a C program
Is there a way to include a library only if it is available to the compiler?
I thought about checking it with #ifndef (as shown below) but it just checks if a macro name is not defined and what I really need is to check if the compiler can reach to…

Wesley Gonçalves
- 1,985
- 2
- 19
- 22
4
votes
4 answers
How to reduce compilation times with Boost Asio
Boost.Asio is great library but it has one huge drawback -- extreamly slow compilation times. A simple implementation (really simple) of HTTP protocol (about 1k lines of code) requires about 13.5s to compile under GCC 4.4!
I tryed to use PCH but it…

Artyom
- 31,019
- 21
- 127
- 215
3
votes
0 answers
How can I compile faster with clang?
I have a visual studio 2019 C++ project that I am converting to clang and I noticed that the clang version compiles quite a bit slower as reported by the -ftime-report switch, which on average says that clang takes about 1700ms to compile while the…

mbl
- 805
- 11
- 18
3
votes
5 answers
Why string addition takes so long to build?
I am adding text in UIlabel, & its cost to performance(i have used build time analyser using this link). how can i optimise this code ?
for value in model?.offerings ?? [] {
offeringsLabel.text = offeringsLabel.text! + " | " + (value.name ??…

Amit
- 556
- 1
- 7
- 24
3
votes
1 answer
constexpr variables defined in header evaluated multiple times in compile time
Consider the following header file, which consists of slow constexpr function, which is used to initialize a global variable:
constexpr int slow_func() {
for (int i = 0; i < 100*1024*100; ++i)
;
return 0;
}
constexpr int g_val =…

Mikrosaft
- 195
- 1
- 8
3
votes
1 answer
How to use precompile header with boost::asio
I have a project that has some main.cpp and the following precompile header:
#ifndef PRECOMPILE_H
#define PRECOMPILE_H
#include
#include
#include
#include
#include…

DeadWarlock
- 720
- 6
- 23
2
votes
1 answer
What are "responsibilities" of c1xx.dll and c2.dll in visual studio compilation process?
I'm trying to analyze the causes for long compilation times in my work (Visual studio 2017, many C++ and some C++/CLI projects), so I've turned on the /Bt+ flag and got the nive detailed output regarding how much time c1xx and c2 spent in each file.…

Anorflame
- 376
- 3
- 12
2
votes
1 answer
Memoization for compile time functions
I'd like to lazily evaluate functions. Since calculating the return values are expensive, I have to use memoization, especially for the called subfunctions, otherwise the calculation's time complexity explodes exponentially. I need the results at…

Tamas
- 3,254
- 4
- 29
- 51
1
vote
2 answers
C++ long compilation time of const array
I'm making a game in Node.js with a C++ component. This C++ component is invoked often (as a subprocess) and is a bottleneck. Thus, I hardcoded its assets as const arrays to make it run faster.
However, I noticed that my C++ code takes a long time…

Maze
- 63
- 6
1
vote
0 answers
How to speed up Rust compile times by splitting my project
I have a Rust project of ~5k lines and about 15 dependencies. Compiling this takes pretty long, so I used cargo -Z timings to see what was causing the bottlenecks. Basically, packages related to jsonrpc seem to increase the compile time a lot, but…

Emre
- 503
- 4
- 7
1
vote
1 answer
Compile-time performance of constexpr computation
I have some non-trivial C++17 functions marked as constexpr. They are doing graph-related computation (depth-first traversal) and general algorithms (e.g., find, sort, unique...).
If I try to force evaluation at compile-time by putting the result in…

Bérenger
- 2,678
- 2
- 21
- 42
1
vote
3 answers
How to modify the TimeDateStamp field in PE file header?
I am writing a python program to modify the compilation time of PE files. Based on my research, the compilation time is stored in the file header under the TimeDateStamp field. However, I only managed to find ways to read the TimeDateStamp…

wyje
- 31
- 1
- 4
1
vote
1 answer
Insert file or DB value into compilation constant (Visual Basic)
imagine the following code in VB.NET:
#Const TestCode = True
#If TestCode Then
Console.WriteLine("Test code enabled.")
#Else
Console.WriteLine("No test code.")
#End If
These conditions are executed in compilation time, but now I'm trying to…

Daniel Serrão
- 481
- 1
- 6
- 17
1
vote
1 answer
Automatically generated .cpp file takes extremely long to compile
I have automatically generated a huge, but very simple .cpp file. It defines a class:
#include
#include