Quantcast
Channel: User Alex Lop. - Stack Overflow
Viewing all articles
Browse latest Browse all 39

Answer by Alex Lop. for How to link two global variables to same address using linker script, C language?

$
0
0

This doesn't directly answers your question but I would suggest defining a geter function in provider.h:

const int *getConfigProvider(void);

and in provider.c

const int *getConfigProvider(void){    static const int config_provider = 1;    return &config_provider;}

This somehow encapsulates the implementation to the consumer and achieves what you are looking for eventually.

Note:

In case of int the return type of getConfigProvider may be just int. In case of a more complex type (struct), it is better to use const pointer to it.


Viewing all articles
Browse latest Browse all 39

Latest Images

Trending Articles



Latest Images

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