简体   繁体   中英

C++ anonymous namespace: Variables initialized to 0?

There is a related unanswered question here:
c++ - Variables auto-initialized to 0 in unnamed namespace? - Stack Overflow

When I have a global function pointer in CI can declare it static and it's initialized as NULL and only available for my file. In C++ I'm switching a lot of stuff to anonymous namespaces but I'm curious if they hold that same guarantee. If I have a function pointer in an anonymous namespace will it be initialized to null?

Thanks

All variables with static storage duration are zero-initialized when the program starts. These include all variables declared at namespace scope (in the global namespace or in any other namespace, including an unnamed namespace).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM