Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70058

Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding

From Soviet_Mario <SovietMario@CCCP.MIR>
Newsgroups comp.lang.c++
Subject Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding
Date 2019-11-25 12:44 +0100
Organization A noiseless patient Spider
Message-ID <qrgerf$svd$1@dont-email.me> (permalink)
References (10 earlier) <qr8pu5$657$1@dont-email.me> <qr99qg$ats$1@dont-email.me> <qren31$fs3$1@dont-email.me> <qreqkn$51v$1@dont-email.me> <dd32ef20-e26e-45d5-a5b6-8284c772669b@googlegroups.com>

Show all headers | View raw


On 24/11/2019 22:46, Öö Tiib wrote:
> On Sunday, 24 November 2019 22:53:53 UTC+2, Soviet_Mario  wrote:
>>
>> I was declaring some 3 lines long function as inlined
>> But, as I started to get their address and populate an array
>> of pointers, I removed the inline suggestion.
>>
>> just for, lol :) precaution.
>> What's the effect of inline linkage when one takes the
>> address of a function (and stores it) ? I assumed, without
>> reading documentation supporting this, It would just ignore
>> inline suggestion.
>> Or is it undefinite behaviour ?
> 
> There are no inline linkage. Functions declared inline (or constexpr
> that is implicitly inline) have external linkage by default.
> The sole "benefit" we are guaranteed to get from inline is that we
> may include same header that defines the inline function in multiple
> translation units without violating ODR. Same benefit we get with
> function templates.
> 
> So removal of inline from non-template function when it is included
> from multiple translation units leads to ODR violation and undefined
> behavior.
> 


uhm ... I must admit I did not understand most.

 > There are no inline linkage.

in general or in this case ?

 > Functions declared inline (or constexpr
 > that is implicitly inline) have external linkage by default.
 > The sole "benefit" we are guaranteed to get from inline 
is that we
 > may include same header that defines the inline function 
in multiple
 > translation units without violating ODR.

I'm not sure : then Inline seems to grant the possibility of 
"redefinition" without redefining (as it is not considered a 
real function) ? Right ?

I tend to embed some very short function in headers instead 
of a "pure" interface description and put ALL code in the 
.CPP unit. Is it a bad practice ?

In case it is not a so bad habit :
* I ought to add inline in all functions in the headers ?
* It is a "must" only if I wish to include the same headers 
multiple times in different .CPP units ? (to avoid the 
redeclaration) ?
* in headers I actually put "safeguard" like

#ifndef THIS_HEADER
#define THIS_HEADER
.....
.....
.....
#endif

structure.
* Shouldn't this protect against the multiple useless 
inclusion ?
Are there scenarios where a multiple REAL inclusion is 
useful ? I can't figure out any ...


 > Same benefit we get with
 > function templates.

sorry this point is obscure to me, I am very rusty with 
templates :\




-- 
1) Resistere, resistere, resistere.
2) Se tutti pagano le tasse, le tasse le pagano tutti
Soviet_Mario - (aka Gatto_Vizzato)

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Soviet_Mario <SovietMario@CCCP.MIR> - 2019-11-24 21:53 +0100
  Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Öö Tiib <ootiib@hot.ee> - 2019-11-24 13:46 -0800
    Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Soviet_Mario <SovietMario@CCCP.MIR> - 2019-11-25 12:44 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Öö Tiib <ootiib@hot.ee> - 2019-11-25 06:55 -0800
  Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-25 13:18 -0500
    Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding David Brown <david.brown@hesbynett.no> - 2019-11-26 08:22 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Paavo Helde <myfirstname@osa.pri.ee> - 2019-11-26 10:19 +0200
        Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding David Brown <david.brown@hesbynett.no> - 2019-11-26 10:15 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-26 11:59 -0500

csiph-web