c++ - Static libraries. Importing and exporting inline functions -
this question arose while implementing static library.
want check guess , gain information on using inline functions in static libs.
my guess iplementator of static lib can not export inline function in library
due inline statement implemented compiler(it compiler whether make function inline) placing low level commands representing operations in function body code segment operations won't placed in tables of export/import , therefore can't processed linker , therefore can't included librarian code of application static lib attached. logic right?i guess importing function inline allowed wonder how implemented, because compiler`s responsibility on linkage state there librarian, means must undertake actions in order make function inline.
yes, inline functions typically placed in header, function body directly visible compiler everywhere function used. lets compiler evaluate whether generate inline code function in particular instance.
this doesn't arise -- "an inline function shall defined in every translation unit in odr-used." (§3.2/3). means if compiler going generate function inline, goes library object code includes inline expansion of code function. since it's possible function may not expanded inline @ every use, there typically definition of function in library, definition used (at least primarily) normal function, not expanded inline.
linkers can generate code though. regardless of whether function or isn't inline function language standard, , defined in same or different translation unit 1 it's used, linker may able generate inline code anyway.
to make long story short, inline keyword has little or no effect on typical compiler far whether function's code generated inline or not. main (if not sole) effect changes one-definition rule -- being inline means multiple (identical) definitions of same function can exist without causing problem.
Comments
Post a Comment