rodolfobandeira / iex-cpp-client

IEX Finance API C++ Client. Stock Tracking, Companies Information, Financial Reports, Dividends, Statistics, Etc
MIT License
7 stars 4 forks source link

Static in namespace{} in IEX.h #22

Open Chudleyj opened 6 years ago

Chudleyj commented 6 years ago

Why are the functions in the empty name namespace static? g++ *.cpp -std=c++11 -ljsoncpp -lcurl -o exa.out && ./exa.out AMZN -a compiles fine without the static keyword.

mpherg commented 6 years ago

https://stackoverflow.com/questions/4725204/use-of-static-variables-and-functions-in-global-scope

Sent from my iPhone

On Oct 17, 2018, at 10:26 PM, Chudleyj notifications@github.com wrote:

Why are the functions in the empty name namespace static? g++ *.cpp -std=c++11 -ljsoncpp -lcurl -o exa.out && ./exa.out AMZN -a compiles fine without the static keyword.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Chudleyj commented 6 years ago

https://stackoverflow.com/questions/357404/why-are-unnamed-namespaces-used-and-what-are-their-benefits

Empty namespace and static are redundant in this case aren’t they?

mpherg commented 6 years ago

Yes, I believe empty namespaces are the C++ preferred way to ensure that a free function is local only to the translation unit.