Questions tagged [inline-functions]

By using keyword 'inline' in function definition, programmer can request that the (C/C++) compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined.

From wikipedia:

In various versions of the C and C++ programming languages, an inline function is a function upon which the compiler has been requested to perform inline expansion. In other words, the programmer has requested that the compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined. (However, compilers are not obligated to respect this request.)

Typical inline-function in C++:

inline int getLength() const { return _length; }

Typical inline-function in C:

inline int max(int a, int b) 
{ 
    return (a > b) ? a : b;
}

See wiki page for more info.

174 questions
0
votes
1 answer

Javascript variabes scope in inline functions

Why is this not working as expected: $(function(){ var datas=[[1],[3]]; var functions=[]; for(var i in datas ){ var data=datas[i]; functions.push(function(){ $("div").append($("

").text("data[0]="+data[0]+",…

pknoe3lh
  • 374
  • 3
  • 10
0
votes
1 answer

How do I rename a sharePoint file to include a date using Nintex

I'm trying to use a 2 workflows to archive any files when created or updated. The first simply moves a copy to a separate doc library. no issues The second should rename the file once it arrives to append a date (and possible timestamp) to the end…
0
votes
2 answers

Defining an inline operator in a different file than the declaration

I want to define operators for a class I created, I want the operators to be inline I also want the definition be in the .cpp file while the declaration is in the .h file I tried to do this: Vector3D.h class Vector3D { ... }; inline Vector3D…
SIMEL
  • 8,745
  • 28
  • 84
  • 130
0
votes
6 answers

c++ inline functions

i'm confused about how to do inline functions in C++.... lets say this function. how would it be turned to an inline function int maximum( int x, int y, int z ) { int max = x; if ( y > max ) max = y; if ( z > max ) max = z; …
user69514
  • 26,935
  • 59
  • 154
  • 188
0
votes
1 answer

Trying to understand an inline function

I am studying the following function: inline xint dtally(xint x) { xint t = 0; while (x) t += 1 << ((x % 10) * 6), x /= 10; return t; } I just want to know what makes this feature i.e. which computes and stored in the variable t.
Kevin
  • 1,151
  • 1
  • 10
  • 18
0
votes
1 answer

Keil ARM C compiler: troubles with inline functions

I'm porting the real-time kernel TNeoKernel to the Cortex-M architecture, so I've installed Keil and am trying to build the kernel. However, I'm facing unexpected issues: the compiler seems not being able to handle inline functions. Here's simple…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
0
votes
2 answers

Inline SQL function which sometimes must update database

Is it possible to create a function/procedure, which could be used in a SQL statement like this: INSERT INTO Journal(ProductID,Quantity) VALUES(LookupOrCreateProduct('12345678'),5) LookupOrCreateProduct should look up a product table by string…
Janeks Bergs
  • 224
  • 3
  • 13
0
votes
2 answers

Convert an inline function to a macro

I have a 1 line inline function which is part of a hotspot in my code. I would like to see if changing this to a macro would be beneficial. Writing as a function I did not have to worry about side effects. But how do I write a macro for this without…
arunmoezhi
  • 3,082
  • 6
  • 35
  • 54
0
votes
1 answer

Code composer inline function linker error

I am working with Code Composer Studio and I need to inline some functions. So I put them in a header file (or in .inl file referred by a header, both ways) and try to build my project. The problem comes when I increase the optimization level. The…
Rizias
  • 211
  • 6
  • 12
0
votes
1 answer

ddply inline function on multiple columns

How can I pass a vector/list of columns to a plyer:ddply inline function? This code works: newdf <-ddply(olddf, .(V1, V2), function(df) c( mean(df$V3), + mean(df$V4), + mean(df$V5),…
John Williams
  • 75
  • 1
  • 1
  • 8
0
votes
2 answers

How do i implement this delegate?

Action doesnt seem to support params string[] as a param so i wrote delegate void WriteFn(string s, params string[] ls); i have this function void blah(WriteFn Write, string fmt, params string[] a) Now i would like to write an function but i cant…
user34537
0
votes
2 answers

Python - Inline get one member of tuple from delegate

From a previous question functions cannot be defined inline in a dictionary object. However, I just have this simple case, def getExtension(fileName): return os.path.splitext(fileName)[1] funcDict = { 'EXT': getExtension, # maybe…
cheezsteak
  • 2,731
  • 4
  • 26
  • 41
0
votes
3 answers

c++ Inline function for array multiplications of 10000

I am tasked with two programs and this is the second one. The first program involved no calculation() function and to time the program when it started and finished. My computer will display anything from .523 seconds to .601 seconds. The second…
user2899211
  • 63
  • 1
  • 8
0
votes
2 answers

Compiler/Linking Error: Freedup

I've been trying to compile a program for hardlinking duplicate files called freedup. I did try to email the author/maintainer of the program, but it's been a long time and I haven't heard anything back from him. I'm trying to compile the program…
user226704
0
votes
1 answer

How to use a C macro / inline function to with a variable function name?

Essentially, I'm simulating object-oriented programming in basic C, due to necessity. For my own convenience, I'd like to use a macro or an inline function to reduce the amount of code I need to write. For my 400+ variables, each needs a structure…
1 2 3
11
12