Quantcast
Channel: Active questions tagged 22.04 - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4439

Compatibility rules to follow if we want to modify a function definition in a shared library used by our program

$
0
0

I'm on an Ubuntu x86_64 system.

I have this source file main.c that uses the fx function defined in the shared library libfx.so :

int fx( int a, int b);int main( void ){    int x = fx( 50, 30 );    return 0;}

Here is the definition of fx in the file fx.c used to create the shared library :

int fx( int a, int b){    return a + b;}

Questions :

1 ) Is it correct to say that we can modify the function definition internally as we like without causing incompatibilities ( I'm not referring to logical incompatibilities but just if it is correct from a technical standpoint) ? For example, could we do the following ?

int fx( int a, int b){    return a - b;}

or

int fx( int a, int b){    if ( a > 10 ){         return a + b;    }else{         return a - b;    }}
  1. Is it correct to say that incompatibilities occur if we modify any of the following :

return type

function name

numbers of paramters

type of paramaters

3 ) Do these principles also apply to single object files ? For example an object file called A that uses a function defined in B


Viewing all articles
Browse latest Browse all 4439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>