187 questions
0 votes
1 answer
86 views
A bizzare phenomenon on inline function? [closed]
While I tried to understand inline functions, I found myself in a rabbit hole which is very deep. I get to know that inline is a function specifier, that inline is a mere hint to a compiler, that it's ...
3 votes
0 answers
42 views
Initializing an mpz_t variable with a static function in between translation units
I am writing a cryptographic program for my bachelor's. I've been uzing an mpz_t variable for exponentiation with the PBC library. Currently, to avoid running mpz_init on every exponentiation, I only ...
0 votes
0 answers
60 views
C/C++ inline functions in a static library (.h file vs .c file)
The problem is I do want to define a function thats must be inline but I can't define it in the .c file of library becouse it's only be inline for in own file of library. Where should I declare my ...
0 votes
1 answer
57 views
how to ask a closure to return a borrowing at the end of its scope?
Considering the following function body: fn update_acc(&mut self, acc_rub: &Vector3<f32>, _t: u64) -> () { let acc = Self::rub_to_frd(acc_rub); if acc.norm() <...
0 votes
1 answer
103 views
Is there a way to automatically "lift" function-like macros to real inline functions?
I'm assigned to review and renew an old private library, which contains tons of do { .. } while(0) macros. After some investigations, I decided to replace them with static inline functions. After some ...
3 votes
0 answers
122 views
C++ STL: The third parameter of sort(), why the functor is faster than inline function? [duplicate]
inline bool mycmp(int i, int j) { return (i < j); } class mycmp2 { public: bool operator()(int i, int j) { return (i < j); } }; above is my example. I want know why the ...
2 votes
2 answers
178 views
inline keyword causes linker error in Clion
I have a strange error concerning the inline keyword, this is just a sample code I wrote: #include <stdio.h> #include <stdint.h> uint8_t inline LIB_MATH_BTT_u8GetMSBSetBitPos(uint32_t ...
0 votes
1 answer
52 views
Friend function not callable from template class operator overload
I am trying to set up a class for representing 2-3D vectors. It's a template class that takes in a Coord type (integral/flaoting point representation of coordinates) and Dim (number of dimensions) as ...
-1 votes
2 answers
337 views
Swap operation with inline function
#define INLINE static inline __attribute__((always_inline)) INLINE void swap(int a, int b){ int tmp = a; a = b; b = tmp; } int main(){ int x = 10; int y = 20; swap(x, y); ...
0 votes
0 answers
134 views
Is using an inline function a correct way of handling needing to access the same data from different structures given compile settings?
So I've got a rendering engine where in certain applications, it makes sense to use a vertex buffer, while in other applications it makes sense to use a triangle buffer. I'll briefly explain the ...
6 votes
3 answers
812 views
Is the old meaning of the inline keyword deprecated in C++?
On the cppreference page for the inline specifier, it says, The inline specifier, when used in a function's decl-specifier-seq, declares the function to be an inline function. An inline function has ...
1 vote
0 answers
63 views
How to deal with incompatibility in required language standards and/or extensions between different libraries?
I recently root caused a linking problem in our build after upgrading googletest from 1.8.1 to 1.12.1. Specifically, the problem occurs because we use -fkeep-inline-functions when gcov is enabled and ...
0 votes
1 answer
48 views
Confusion in Bjarne's PPP 2nd edition Pg. 316
• The function will be inline; that is, the compiler will try to generate code for the function at each point of call rather than using function-call instructions to use common code. This can be a ...
2 votes
0 answers
87 views
Should modifying an inline member function cause recompiling the whole class?
Hello I know that if the compiler inlines a function, it replaces its body (statements) in each call to it. I've read this from Stroustrup's programming principles and practice using c++ about ...
1 vote
1 answer
210 views
Unresolved external symbol "enum days __cdecl operator++(enum days)" (??E@YA?AW4days@@W40@@Z) referenced in function main
I write a small program to encounter the next day by giving day. I write a program in day_enum.cpp file:- #include <ostream> #include "AllHeader.h" using namespace std; inline days ...