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
63
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
58
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
104
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
181
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
338
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
828
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 ...
0
votes
2
answers
212
views
Will an inline function execute if you don't select it from the view?
Say you have a View that selects a couple properties from a table. One of them is an inline function. After the view is created, will it execute the inline function if I don't select that property ...
0
votes
2
answers
537
views
Include multiple inline functions and multiple CTEs in a WITH clause in a single query
Oracle 18c:
What is the syntax for including multiple inline functions and multiple CTEs in a WITH clause in a single query?
Function #1:
function fucntion1(num in number) return number
is
begin
...
5
votes
3
answers
1k
views
Can I inline a function which uses a static variable?
I have this code:
// my.h
#ifndef MY_HEADER
#define MY_HEADER
int create_uid();
#endif
// my.cpp
#include "my.h"
static int _next_uid = 0;
int create_uid()
{
return _next_uid++;
}
...
0
votes
1
answer
248
views
How to compile C header with inline functions using g++11?
I'm having problem compiling cpp file with C inline functions using g++11. Following is an example:
c.h:
#ifndef C_H
#define C_H
#ifdef __cplusplus
extern "C" {
#endif
inline int add(int a,...
0
votes
0
answers
133
views
In inline functions, scalar types should be passed by value or reference?
I know, the question of passing scalars by value vs. by reference has been asked and answered gazillion times before, and I know - in general - they should be passed by value. But what about inline ...
2
votes
1
answer
507
views
SQL Server 2019 infinitely recompiles inline table valued function that does full text search with Parameterization = Forced
I have hit a problem with SQL Server that results in it infinitely recompiling a function.
To reproduce, create a new database with the option Parameterization = Forced or execute the following on an ...
5
votes
1
answer
902
views
A "constexpr" function should not be declared "inline"
By analyzing code using SonarLint, I got a message (the title of the question) about a destructor that is declared like below:
class Foo
{
public:
. // default ctor
. // parameterized ctor
.
...
1
vote
1
answer
624
views
Converting inline function to normal function
I am looking to convert an inline function of the following signature to a non-inline function
const onMouseEnter = (itemName: string): void => {
alert(itemName);
};
I tried doing as follows but ...
3
votes
1
answer
284
views
Why are certain Kotlin library functions (e.g., some extension functions in String.kt) marked as inline even if they are no higher-order functions? [duplicate]
The Kotlin documentation itself states the following:
If an inline function has no inlinable function parameters and no reified type parameters, the compiler will issue a warning, since inlining such ...
3
votes
1
answer
211
views
Is there any practical difference between an inline function having internal and external linkage, with compiler optimization?
If a function is static inline, inline here works only as a suggestion. With either static or static inline the function has internal linkage, and the compiler knows this function cannot be called ...
0
votes
1
answer
287
views
React gives a 301 error with inline functions but not with inline anonymous ones
This code generates a React error 301: https://reactjs.org/docs/error-decoder.html/?invariant=301
const [count, setCount] = useState(0)
return <>
<p>{count}</p>
<button ...
1
vote
1
answer
1k
views
One header file in multipe cpp files: Multiple definition [duplicate]
I am trying to access one header file in multiple C++ files. The header file is defined as follows:
#ifndef UTILS
#define UTILS
void toUpper(string &str) {
for(unsigned int i=0; i<str....
2
votes
1
answer
771
views
Use inline function in subquery (in a WHERE clause)
In a COTS system, I am able to enter a SQL WHERE clause.
Example of WHERE clauses that work:
worktype = 'Corrective Maintenance'
or
1 = (
with
cte as (select 1 as calc from dual)
...
0
votes
2
answers
1k
views
How to make an inline function remove itself when its being used as a listener in kotlin
I have hit a wall with this one and I can't find any question with a solution for this here in SO.
I am using a PagingAdapter method, from Google's Paging library, that receives an inline function as ...
0
votes
1
answer
183
views
External definition and inline definition
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
I'm experimenting with inline and external definitions and here are 2 source files linked together:
foo.c:
#include <stdio.h>
void foo(void){
...
1
vote
1
answer
426
views
onClick inline function works different from outside function
I have a newbie question that is probably really easily explained. I have an image that has an onClick property added to it. If I call an inline function to log something, it works as expected. It ...
1
vote
1
answer
210
views
Transform collection of items with another collection inside in kotlin
I have a collection of items. And each item has another collection inside.
To transform the first collection I'm using mapNotNull.
I'm trying to achive something like this:
data class QuestionData( ...
0
votes
1
answer
953
views
Avoid calling T-SQL function multiple times
I have an inline function which result I need multiple times during a T-SQL script execution. The results from the function are quite large. I am trying to figure out how to call the function only ...
0
votes
1
answer
5k
views
Configuring CMake raylib-cpp for VScode
I have installed raylib and ran the example .c files with success in VSCode and Notepad++.
I'm trying to execute the files from this repo raylib-cpp/projects/CMake
I haven't changed the files from ...
0
votes
1
answer
218
views
C++ inline performance decrease
I've been trying to figure out a fastest way to change vector of bytes to 64bit integer, This is a code I've used for benchmarking
#include <iostream>
#include <ctime>
#include <ratio&...
-1
votes
1
answer
478
views
Inline function of my code is not storing string the string value
I am following an online tutorial which is quite similar to my code, but not exactly the same. I have modified it so that I can have a better understanding of it, but I am having problems getting/...
5
votes
1
answer
4k
views
flutter anonymous / inline functions for widget properties
I am new to dart and flutter, I am trying to use an inline function to return a value.
SizedBox(
height: _getheight()
),
double _getheight(){
//do some stuff
return 20.0;
}
//WORKS
SizedBox(
...
0
votes
1
answer
500
views
ODR violation due to anonymous namespace in header
From reading the standard I was unable to figure out if the following code violates ODR:
// a.h
#ifndef A_HEADER_FILE
#define A_HEADER_FILE
namespace {
int v;
}
inline int get_v() { return v; }
#...
2
votes
1
answer
231
views
Why my inline functions have linking error?
I am learning C++ and currently testing inline functions. If I run my code now I will have linking error, but if I change
inline void Test::print40()
to
void Test::print40()
everything would be fine. ...
2
votes
2
answers
825
views
Why is constexpr solving duplicated definition?
I have a header file where string are defined as static global.
namespace space {
#define NAME(P) static std::string const s_##P = #P
NAME(foo); NAME(bar); //... other values
#undef NAME
}
...
-1
votes
1
answer
46
views
What is this syntax in this code about lambda of Kotlin?
I'm studying about Kotlin's inline function just after
Kotiln's lambda,,,
below code is about Kotlin's inline function example
I know that "return" can't be in lambda in Kotlin
But What is a "...
1
vote
1
answer
72
views
C inline functions [duplicate]
As far as i know, inline functions in C work pretty the same way as in C++ when used in single translation unit and there's no need to dive into extern inline difficulties in such a case. However, the ...
1
vote
1
answer
233
views
Does extern matter for function declaration with inline?
As specified in the Standard
If the declaration of an identifier for a function has no
storage-class specifier, its linkage is determined exactly as if it
were declared with the storage-class ...
1
vote
2
answers
2k
views
how to pass local variable and argument of same name (using this keyword )inside lambda functions in c++?
#include <iostream>
#include <functional>
int main(){
int a = 10;
std::function<int(int)> functionPointer = [a](int a)-> int{ return a + a + 100 ; };
int returnValue =...
1
vote
1
answer
215
views
What is the meaning of file-static out-of-line, global out-of-line and no out-of-line copy of function in inlining
I was reading the source code of OS/161 and encountered inline support code. I am not able to understand the comment provided. The comment is :-
/* ...
2
votes
1
answer
1k
views
Multiple inline functions in Oracle
I have the requirement to call my 2nd inline function into my 1st function. I am not able to achieve this one and getting error only.
with
function add_string(p_string in varchar2) return ...
2
votes
1
answer
790
views
C++ redefinition link error when not using "inline" or "static" keywords with classless functions
So I realize that when including a ".h" file, the compiler essentially copies the contents of that file to the point it was included. So obviously if I had "Utils.h" included in many files, if utils.h ...
-1
votes
1
answer
203
views
multiple definitions of an inlined function in 2 or more TU
I was reading about inline functions and how they could have multiple definitions in different Translation Units but those definitions must be the same.
So what I was thinking is that if I declared ...
1
vote
2
answers
620
views
How to make a function inline in C++
To make a function inline should I add the keyword inline in function prototype or in function definition or should I add the inline keyword both in function declaration and function definition.
1
vote
2
answers
1k
views
Inline function definition with external linkage containing reference to a static object
There is a constraint 6.7.4(p3):
An inline definition of a function with external linkage shall not
contain a definition of a modifiable object with static or thread
storage duration, and shall ...