3,814 questions
3
votes
1
answer
123
views
When is the definition of an exported function available to an importing TU?
Consider the following translation unit:
export module Example;
export inline void fn1();
export void fn2();
export void fn3();
void fn1() {}
void fn2() {}
module :private;
void fn3() {}
Firstly, ...
Best practices
1
vote
8
replies
192
views
Why shouldn't I `inline` every function in my C++ project to get out of having to bother with cpp files?
Say I'm developing a C++ command line tool of moderate scope. I have a couple dozen classes, and a main() driver function that lets the user do a few things with the tool.
I could have one .hpp and ...
Advice
2
votes
7
replies
126
views
Do all definitions of an inline function in C share the same address?
I know that it's possible to take the address of an inline function, just like with ordinary functions. But if each translation unit has its own inline definition, and I take the address of the ...
4
votes
1
answer
99
views
Why is attribute noinline ignored by gcc-15.1.0 in this example?
Looking at this benchmark about a custom std::function implementation: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/blob/main/Chapter06/09_function.C
I tried to ...
0
votes
0
answers
31
views
Large empty space on the right side of chat bubble: need iMessage style wrapping
My chat bubbles leave a large empty space on the right when messages wrap into multiple lines.
I want the behavior like iMessage/WhatsApp:
Bubble shrinks to fit short text.
Long messages use max ...
4
votes
2
answers
244
views
Why the compiler decides when to inline functions? Why can't I order it to do so?
It is a common statement that compilers take the final decision about inlining. But what if the developer is sure that in a certain place function inline is definitely good? For example, imagine a ...
3
votes
1
answer
106
views
inline (non-static) function in C-source file
I've seen something like that in a C-code and I'm wondering what it exactly does:
file.h
int f(int x);
file.c
inline int f(int x)
{
...
}
Basically the function is declared as inline in the C-...
5
votes
1
answer
148
views
Is an "inline function template" considered a "inline function" with respect to ODR rules?
In the C++20 draft (N4868) there are two relevant rules about definition reachability:
Inline functions must have their definition reachable in every translation unit in which they are ODR-used:
[...
6
votes
1
answer
119
views
When inline function definition and extern function declaration are all present in one .c file, no link error is observed
Even though this might look like duplication, I'd claim that it isn't.
Why does a compiler make the Foo function, which is defined in foo.c as inline double Foo() { return 1.2; }, a global function if ...
4
votes
2
answers
146
views
Usage of exported inline variables in c++20 modules
Is there any use of exported inline variables in c++20 modules?
Is there any difference between
export constexpr auto val1 = 0;
export const auto val2 = 0;
export auto val3 = 0;
and
export inline ...
0
votes
1
answer
193
views
js v8 function inlining
I'm intresed how and in what cases V8 perform inlining.
I know that V8 can inline functions to eliminate call cost, but i dont konw the rules for it to happen.
I got how it works in obvious cases, ...
0
votes
2
answers
61
views
Tooltips: html and inline css only, no js
I suspect the answer to this question is simply that it's not possible, but thought I would ask in case I've missed something.
I am a teacher using the Canvas LMS (instructure). I can code, I have an ...
0
votes
0
answers
58
views
Generating Java code at runtime to replace legacy reflection-based data mapping. How to use @ForceInline and and module export questions
I’m writing a library that generates Java code at runtime, and so far it’s producing good results.
The problem: some legacy software (read: "adopting polymorphism now is kinda impossible") ...
13
votes
1
answer
368
views
Why does Rust's standard library mark generic functions as #[inline]?
I'm was reading through parts of Rust's standard library as inspiration for a library I'm working on. I noticed that many functions are marked #[inline] despite them being generic.
Here's a few ...
1
vote
1
answer
156
views
How to call an inline method from within a scala 3.6.4 macro?
In a scala 3.6.4 serialization library I am developing there is the DiscriminatorCriteria type-class that allows the user to determine which discriminator value to use for each variant P of a sum-type ...
15
votes
2
answers
809
views
MSVC calls wrong virtual method when storing a pointer to virtual method in a static inline variable
I'm encountering unexpected behavior on MSVC when storing a pointer to a virtual method in a static inline variable. The issue does not occur on GCC or Clang.
Specifically, when I store a pointer to a ...
0
votes
0
answers
107
views
Python telebot inline buttons do not response for some reason. Button handlers not responsing
Python 3.13.2,
pyTelegramBotAPI-4.27.0,
Windows 10
I have a problem with Python telebot inline buttons. It worked fine for a long time, without any problems. At some point it stopped to work. I did ...
0
votes
2
answers
120
views
I did some inline code for an assignment and I was wondering if using it would be more efficient with or without
The goal of the assignment was to initialize an empty list called rand_array then fill it with 10 unique random numbers
I figured out the assignment normally as per the teacher's directions:
import ...
3
votes
1
answer
108
views
Why is it a problem to call static inline function in an extern inline function?
// lib.h
#pragma once
static inline int static_inline(int x) { return x; }
inline int extern_inline(int x) { return static_inline(x); }
// lib.c
#include "lib.h"
extern inline int ...
0
votes
1
answer
211
views
Can an inline method cause a race condition for an object referenced by the reference type?
I have an instance variable or property called Setting that is shared among threads.
A new instance will occasionally be assigned to this variable by other threads.
The method using the Setting will ...
2
votes
1
answer
175
views
Will removal of all `inline` keywords from my code leave my C program semantically correct?
Note: the same question I've asked but for C++ is answered here: Will removal of all `inline` keywords for functions and methods leave my program semantically correct? . Given that C is a related but ...
0
votes
0
answers
61
views
MailKit does not see attachment (content-disposition: inline)
I am tryilng to save attachments from emails using MailKit.
I have emails with attachments, which are not seen by MailKit. When these messages are opened in Outlook I see that they have attachments.
I ...
6
votes
3
answers
276
views
Will removal of all `inline` keywords for functions and methods leave my program semantically correct?
Inspired by the article "Why const Doesn't Make C Code Faster", I want to carry out a similar experiment in my code base, but for inline.
I have a feeling that a lot of code currently marked ...
0
votes
0
answers
29
views
Jodit inline toolbar auto-open
Is there a way to keep Jodit's inline toolbar open (if there's selected text) after a choice is made from the toolbar? If not, is there a way to auto-open the inline toolbar if currently there's ...
0
votes
1
answer
500
views
Error: Inline regex not working in koa-router (Unexpected "(" at 10)
I am trying to use an inline regular expression in a koa-router route parameter, but I am getting an error. Here’s my code:
import Koa from 'koa';
import Router from 'koa-router';
const app = new Koa(...
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 ...
2
votes
0
answers
101
views
Inlining Questions in C
I have some C code with a header and source file (with development dating back probably about 15 years). I have some questions about function inlining, which I know only provides a "hint" to ...
1
vote
1
answer
85
views
Does inline create a COPY of the parameters as variables or will it reuse the same from the input?
Here what this problem looks like:
typedef uint32_t StrTableKey_t;
typedef struct StrTableEntry_s
{
char *string;
StrTableKey_t keyhash, keyid;
size_t usages;
} StrTableEntry_t;
typedef ...
0
votes
0
answers
67
views
Difficulties with gcc inline assembler: asm("PUSH EAX;")? [duplicate]
If tried to do a asm("push eax;"), but it did not work.
asm ("push ax;") and asm("push rax;") work fine.
Any suggestions?
1
vote
1
answer
227
views
How does C++17 handle thread-safe initialization of inline static data members across multiple translation units?
I've been learning about inline static variables in C++17 and their initialization across multiple translation units. I understand that inline static variables are introduced to maintain a single ...
1
vote
1
answer
239
views
Can react-native-modal-datetime-picker values be inline and display as native iOS new style inline picker?
Is it possible instead of using an extra time/date component to pop up modal date / time component to have it inline and act the same way?
Currently the only option I see is as below, where calendar ...
-1
votes
1
answer
136
views
Is each static library supposed to get its own copy of an inline variable?
It's supposed to be, according to info I've heard, that if you have a variable such as:
inline int a_var;
or
struct Foo
{
static inline int a_var;
};
In a header file and include that header ...
-1
votes
1
answer
195
views
How to add an inline element after a line-clamped element?
I'm having trouble figuring how to add an inline element by the end of a text block using a line-clamp. The element could be a tag or a hoverable icon in order to display a tooltip.
As I need to use ...
0
votes
0
answers
125
views
Any reason to inline a constexpr variable in an source file unnamed namespace
Is there ever a reason to explicitly inline a constexpr variable that's in an unnamed namespace in a source file?
E.g. in a foo.cc:
namespace foo {
namespace {
inline constexpr uint32_t kFoo = 0;
} //...
0
votes
0
answers
80
views
Confused with "inline" keyword in C [duplicate]
#include <stdio.h>
inline int b(int x) {
return x*2;
};
int main()
{
printf("Hello World %d", b(3));
return 0;
}
Output:
/usr/bin/ld: /tmp/ccGGQWnl.o: in function 'main'...
0
votes
1
answer
187
views
Today, VS Code has started underlining my inline CSS classes in Vue 3 components. How can I remove this?
Not sure, why, tried disabling all extensions to check, and checked in preferences, but as of this morning my Vue 3 component has underlines for classes, regardless of color theme. Like so:
Any ...
1
vote
4
answers
161
views
Is the C compiler allowed to do out-of-order optimization around an inlined function?
Supposing I have a function foo() and an inline function bar():
inline void bar(void) {
// do some stuff
}
void foo(void) {
// some code
bar();
}
Is the C compiler allowed to rearrange /...
1
vote
0
answers
142
views
React: use Ant Design component DatePicker.RangePicker in inline mode
Could you tell me how I can make the DatePicker.ReactPicker dropdown panel with calendars display inline?
i.e. it is necessary that the dropdown calendar is drawn at once and the parent window reacts ...
1
vote
1
answer
76
views
inlining function
I want to inline a function using PRAGMA INLINE but I am not sure how to check if it worked as I expect.
More exactly, I have a function:
create or replace function my_fnc(p1 varchar2, p2 varchar2) ...
0
votes
1
answer
160
views
Write a new Delphi type that lets a method have inline code as a parameter?
Is it possible to have this in Delphi?
DoThis(ShowMessage('SomeMsg ..'); Caption := 'SomeCaption'; Inc(I));
Is it possible to create a new type that handles inline code like this?
For example, we ...
1
vote
0
answers
111
views
Deterministic (programmatic) guidline for function inlining when targetting modern x86 processors?
(IMO) Cons when not inlined:
call is unconditional branch (jump) with stack manipulation, and the x86 instruction table specifies it needs 4 uops/inst. and has reciprocal throughput of 2 for Zen4 ...
2
votes
1
answer
145
views
How to accept inline inputs in a noninteractive powershell script
I'm trying to put together a powershell script that we can use for some custom scripts to a commercial IT monitoring solution (StableNet by Infosim.de). The product has a neat feature on passing on ...
3
votes
0
answers
128
views
Wrap doubles without overhead in Csharp
I'm trying to create a structure that's essentially just a regular double but has a physical unit attached via generics.
My attempts perform terribly, even without generics. Could somebody give me ...
0
votes
0
answers
50
views
inline function is slower
HiALL
I am using MDK arm compiler (No optimization) on stm32f030 chip.
I noticed that function declared with __forceinline takes
more time to execute that without that. I checked that with ...
0
votes
1
answer
111
views
`extern inline` vs `static inline` shared functions. What is the correct form?
There are two possible ways to define shared inline functions:
1st form, extern inline
main.c:
#include <stdio.h>
#include "main.h"
#include "file1.h"
extern inline int f(...
1
vote
1
answer
511
views
How to use `inline` function across multiple C files without the "declared but never defined" warnings?
I want to use inline function across multiple C files. Maybe the MWE would be:
main.c:
#include <stdio.h>
#include "main.h"
#include "file1.h"
// Define the inline function ...
2
votes
0
answers
61
views
GCC+MPICH Link-time optimization generates "inlining failed" warnings for compiler-generated functions
TL;DR: How do I fix* inline failures by LTO on compiler-generated functions?
(* by "fix" I mean "eliminate warnings in a manner consistent with best practice." I want to remove the ...
3
votes
1
answer
101
views
Encapsulation of inline reified method in kotlin
I have written the util class to be used with Flow<> in kotlin. The goal of the class is to simplify error handling and make possible to instantly finish the flow by calling breakFlow() method. ...
0
votes
1
answer
90
views
Change color of inline svg inside <img> tag [duplicate]
I was wondering if it's possible to change the color of a SVG image/icon/logo in an inline html <img> tag, using style="..."
Here's part of my code, it's a button and I want the logo (...
0
votes
1
answer
63
views
Content-Security-Policy violated in jquery.min.js and SessionExpire.js
I am implementing CSP in my application and the browser says CSP has been violated in the following:
1. jquery.min.js: Inline style violation in the following line
t.insertBefore(e, t.firstChild)
2. ...