Questions tagged [compile-time]

Refers to the information that can be inferred or known at the time source code is compiled, as opposed to information that can only be inferred when source code is run. Do not use this tag for questions about the time it takes for source code to be compiled.

In , compile time refers to either the operations performed by a (the "compile-time operations"), requirements that must be met by source code for it to be successfully compiled (the "compile-time requirements"), or properties of the program that can be reasoned about at compile time.

The operations performed at compile time usually include , various kinds of (e.g., type checks and instantiation of template) and .

Programming language definitions usually specify compile time requirements that must meet to be successfully compiled. For example, that the amount of storage required by types and variable can be deduced.

Properties of a program that can be reasoned about at compile time include range-checks (e.g., proving that an array index will not exceed the array bound), deadlock freedom in concurrent languages, or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time).

Compile time occurs before (when the output of one or more compiled files are joined together) and runtime (when a program is executed).

In some programming languages it may be necessary for some compilation and linking to occur at runtime.

There is a trade-off between compile-time and link-time in that many compile time operations can be deferred to link-time without incurring extra run-time.

"Compile time" can also refer to the amount of time required for compilation.

Source: Wikipedia

925 questions
-1
votes
1 answer

Using runtime interface at compile time

I need hardware support (it might be FPGA) at compile time to speed up compile-time computations. To be more specific compile-time training of a neural network. This might use OpenCL to greatly speed up compilation. Would a compiler provide such an…
Sergei Krivonos
  • 4,217
  • 3
  • 39
  • 54
-1
votes
3 answers

Java type parameter in static method compile time

I'm writing universal compare utility, it should be type safe as possible. Idea is to prevent comparing of different class Objects. For example this works OK: UtilityClazz.compare("dd", 1); //OK - compile time error Is there more elegant…
Levijatanu
  • 371
  • 2
  • 17
-1
votes
1 answer

How much do I need to know about compile time vs runtime to comfortably write code in general

I'm a self taught programmer starting to browse info about the range of C languages and Object Oriented Principles for developing iPhone and Android apps. One thing I come across often is mentions of what this or that language does at compile time…
Spilot
  • 1,495
  • 8
  • 29
  • 55
-1
votes
1 answer

C++ invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]

WARNING: Extremely limited knowledge of C++ and coding in general. Please refrain from advanced terminology. for ( i = 0; i < answer.size(); ++i) { if (guess == answer.at(i)) { //to display correct letters in…
-1
votes
1 answer

Check if an expression compiles including all implicit conversion

Consider the following code: void f(auto& i, auto& j) { static_assert(/* SOMETHING */, ""); // function body here... } I want the /* SOMETHING */ part to check whether the following code compiles (taking into account all the standard rules,…
Vincent
  • 57,703
  • 61
  • 205
  • 388
-1
votes
1 answer

Is there anyway to parsing or modifying string during compile time in C?

I want to hide strings in my executable binary because it's really easy to hack. So I want to do some encoding during compile time I want to change string at compile time, for example if i have a string a = "abc" and i want to change a into a =…
demonguy
  • 1,977
  • 5
  • 22
  • 34
-1
votes
1 answer

Android Studio and gradle 's slow build time, what to do in the mean time?

Hello to all my lovely Android Developer I have been building android apps with Android Studio for around 8 months now, everything is great except that the build time with Gradle is SUPER SLOW, even tho there are options in gradle to speed things up…
-1
votes
1 answer

Performance issue: if (isChecked) vs. if (isChecked == true)

Is there any Performance issue in using if (isChecked) vs. if (isChecked == true) in Compiletime or Runtime?
Mohamad Shiralizadeh
  • 8,329
  • 6
  • 58
  • 93
-1
votes
1 answer

How can I encode a property of a value in its type in C?

In a plain C program, I have certain values of some type that may or may not have a certain property, and this property must hold for some users of this value. I wonder if/how we can use the type system to enforce this property at compile time for…
jms
  • 34
  • 1
  • 1
  • 5
-2
votes
1 answer

What interface is achieveing here ? ( compile - time / run - time polymorphsim )?

Question (What my code is trying to achieve in terms of interfaces? (Compile - time / run - time) polymorphism ? Consider below code as an example interface RemoteControl { void turnOn(); void turnOn(int channel); } class TV implements…
-2
votes
1 answer

Is it possible to change the behavior of a #define at compile time depending on a parameter in C?

Having this code: // Called when x is "a" #define do(x) doA() // Called when x is "b" #define do(x) doB() Is it possible to make the preprocessor interpret do("a") as doA() and do("b") as doB() and maybe some other doUndefined() if unknown x…
g00dds
  • 195
  • 8
-2
votes
1 answer

"Derived pointer to member" to "base pointer to member" error

To support some compile time magic I would like to use pointers to members like: struct BaseT { }; struct DerivedT: public BaseT { }; struct TestT { DerivedT testMem; typedef BaseT (TestT::* TestTMemPtr); constexpr TestT() =…
Broothy
  • 659
  • 5
  • 20
-2
votes
2 answers

Compile time function encryption

I was wondering if something like compile time function encryption is possible and if it's possible how can someone achieve it ? And by "compile time function encryption" I mean encrypting the function code during compile time and later on at…
bogding
  • 11
  • 1
-2
votes
2 answers

is there a way to know (and not fail) at compile time if this is a array or an integer?

OP: is there a way to know at compile time if the current object is an array or an integer? #include #define IS_INDEXABLE(arg) (sizeof(arg[0])) #define IS_ARRAY(arg) (IS_INDEXABLE(arg) && (((void *) &arg) == ((void *) arg))) int…
Guillaume D
  • 2,202
  • 2
  • 10
  • 37
-2
votes
2 answers

Is gcc compile time proportional to number of executions or lines of code?

I am using gcc 4.8.5 to compile a c++98 code. My c++ code statically initializes unordered_map of unoredred_maps with ~20,000 total key-value pairs, and overloaded function which will take ~450 different types. This program will be executed on a…
Mikan
  • 89
  • 8
1 2 3
61
62