Peace, language lawyers!
I'm developing a (static) library for a "memory-challenged"
platform (ie, mobile).
I want to (force the compiler to) inline some functions -- that
are not meant to be exported to the library's clients.
Example:
file1.c:
// Exported.
public_foo( void ); // Calls my_bar() and common_bar().
// Private.
static INLINE my_bar( void ); // Only called by functions in
this translation unit.
INLINE common_bar( void ); // May be called from other
translation units, too.
file2.c:
// Exported.
public_another_ foo( void ); // Calls common_bar().
Currently, to inline and prevent exporting, I #include a file with
the static INLINE function.
This is not _standard_ C, but most compilers do provide some
"inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline
functions in a library?
2. Your experience with compilers (especially GCC, VC, ARM's,
TI's): will they allow inlining, especially of non-static
functions, when building a library?
:o)
--
Ian 3 2789
Ian <ha**@spam.co m> wrote: I want to (force the compiler to) inline some functions -- that are not meant to be exported to the library's clients.
Example:
file1.c: // Exported. public_foo( void ); // Calls my_bar() and common_bar().
// Private. static INLINE my_bar( void ); // Only called by functions in this translation unit. INLINE common_bar( void ); // May be called from other
Currently, to inline and prevent exporting, I #include a file with the static INLINE function.
This is not _standard_ C, but most compilers do provide some "inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline functions in a library?
C99 provides the inline keyword. As you note, quite a few C89 compilers
do so as an extension, too. Apart from that, I don't know any way.
Richard
Ian wrote: I'm developing a (static) library for a "memory-challenged" platform (ie, mobile).
I want to (force the compiler to) inline some functions -- that are not meant to be exported to the library's clients.
Currently, to inline and prevent exporting, I #include a file with the static INLINE function.
This is not _standard_ C, but most compilers do provide some "inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline functions in a library?
There are some other ways of doing this. You could remove the names from
your final object (using the strip command) or only include names that
you want to be included (see option --retain-symbols-file of the Gnu
linker). I don't know if this option is available for other linkers.
As you are working on a "memory challenged" device I think this would be
preferable over inline, as inline will include your code multiple times
in your final object.
Another way might be to use static functions instead of inline. This
might take some redesign, as you can only use static functions in the
scope of a module, but it would also get you the same result. The result
will be portable and will not rely on the use of the (non-standard for
pre-C99) inline keyword.
Kind regards,
Johan
--
o o o o o o o . . . _____J_o_h_a_n_ __B_o_r_k_h_u_i _s___
o _____ || http://www.borkhuis.com |
.][__n_n_|DD[ ====_____ | jo***@borkhuis. com |(________|__ |_[_________]_|_____________ _______________ ____|
_/oo OOOOO oo` ooo ooo 'o!o!o o!o!o`
== VxWorks FAQ: http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html ==
Richard Bos wrote: Ian <ha**@spam.co m> wrote:
I want to (force the compiler to) inline some functions -- that are not meant to be exported to the library's clients.
Example:
file1.c: // Exported. public_foo( void ); // Calls my_bar() and common_bar().
// Private. static INLINE my_bar( void ); // Only called by functions in this translation unit. INLINE common_bar( void ); // May be called from other Currently, to inline and prevent exporting, I #include a file with the static INLINE function.
This is not _standard_ C, but most compilers do provide some "inline" keyword as a language extension.
Questions:
1. Is there a readable, manageable, semi-portable way to inline functions in a library?
C99 provides the inline keyword.
... and, a word of caution.
Semantics
[...] Making a function an inline function suggests that calls to
the function be as fast as possible. The extent to which such
suggestions are effective is implementation-defined.
As you note, quite a few C89 compilers do so as an extension, too. Apart from that, I don't know any way. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: qazmlp |
last post by:
// test.h
class test
{
public :
inline void check() ;
} ;
// test.C
inline void test::check() // Is 'inline' optional here?
|
by: Chris Mantoulidis |
last post by:
I am not clear with the use of the keyword inline... I believe you add
it do a function when you implement the function inside the header
file where the class is stored...
But is that all? What am I missing?
If that's all, then why did Bjarne even bother adding it to the
language?
If that's not all, what else can I do with "inline"?
|
by: Grumble |
last post by:
Hello everyone,
As far as I understand, the 'inline' keyword is a hint for the compiler
to consider the function in question as a candidate for inlining, yes?
What happens when a function with extern linkage is inlined? Should the
compiler still export the function?
Or is an inlined function implicitly static?
|
by: Brian Lindahl |
last post by:
I'm using a temporary buffer to transfer some data and would rather
not allocate it on the heap. The problem is that the size of the
buffer is only known upon entry into the function that utilizes it and
I'd rather not waste space or dynamically allocate on the heap (since
it doesn't need to persist). Now I'm planning on utilizing inline
assembly to modify the stack pointer directly to allocate the space I
need.
Here's an example:
|
by: Sharon |
last post by:
Usually it is common to write the class member function in the class H file,
but some people like to write the function body in the C++ file.
Can anybody tell me what are the cases where inline function should not be
written in the C++ file? Or what are the disadvantages of inline function
body in a C++ file?
--
Regards
Sharon G.
| |
by: Anders M |
last post by:
I'm trying to use Inline-code to call Page_load, Page_Init or Page_PreRender
methods.
I've also got a code behind c#-file.
I can define inline methods for buttons and so on...that works fine. But
when I try to call Page_load, Page_Init or Page_PreRender methods it doesn't
work.
Non of the methods get's triggered !?
|
by: shuisheng |
last post by:
Dear All,
If I define a virtual function to be inline, is it really inline? Or it
is inline in some cases, and not in other cases. Would you please help
me to look at the following case.
struct A
{
int i;
A() {i = 0;}
|
by: jg |
last post by:
Does C++ standard require an inline function be generated all the
time ?
For example,
#include <iostream>
using namespace std;
inline int foo()
{
|
by: Shadow Lynx |
last post by:
Could someone sum up the difference(s) between the standard CSS
display: inline block and the non-standard Firefox (Mozilla) display: -
moz-inline-box?
I have used the following in a couple of special situations to render
inline elements (like A and SPAN) as block elements that flow with
inline items and it seems to work, although I know I shouldn't depend
on such:
<style>
|
by: subramanian100in |
last post by:
Can a ctor be declared inline ?
Is it not declared inline to avoid executable code size becoming
huge ?
kindly clarify
Thanks
V.Subramanian
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |