global-namespace

Is there a GCC warning for using symbols from the C library not through namespace std?

非 Y 不嫁゛ 提交于 2021-02-08 12:22:20
问题 Consider the following (buggy) C++ code: #include <cmath> #include <cstdlib> #include <iostream> int main() { if (abs(-0.75) != 0.75) { std::cout << "Math is broken!\n"; return 1; } else { return 0; } } This code is buggy because it calls abs (meaning ::abs ) instead of std::abs . Depending on the implementation, ::abs might not exist, or it might be the C abs , or it might be an overload set including a version for double , like std::abs is. With Clang on Linux, at least in my environment,

Is there a GCC warning for using symbols from the C library not through namespace std?

[亡魂溺海] 提交于 2021-02-08 12:22:06
问题 Consider the following (buggy) C++ code: #include <cmath> #include <cstdlib> #include <iostream> int main() { if (abs(-0.75) != 0.75) { std::cout << "Math is broken!\n"; return 1; } else { return 0; } } This code is buggy because it calls abs (meaning ::abs ) instead of std::abs . Depending on the implementation, ::abs might not exist, or it might be the C abs , or it might be an overload set including a version for double , like std::abs is. With Clang on Linux, at least in my environment,

PHP Global namespace aliases

痞子三分冷 提交于 2020-01-11 12:28:29
问题 Here is the scenario. I am implementing namespaces into my projects. I have my own custom bridge library that calls other libraries like Zend to do the heavy lifting. I have no problem using fully qualified namespaces in my custom bridge library but would like to keep the code as terse as possible in my controllers, models and view. Here is an example of some aliasses i would like to use: use BridgeLibName\Stdlib\Arrays as arr; use BridgeLibName\Stdlib\Objects as obj; use BridgeLibName\Stdlib

How can I export from a Meteor package into my app's namespace?

北慕城南 提交于 2019-12-20 13:59:58
问题 I know how to write Meteor packages but I can't seem to figure out how to have all exports land in my app's namespace, as described in this presentation. This particular package is specific to an app I'm building, and it exports only one method that can be regarded as a decorator on the app's singleton. I tried api.export('MyApp.myMethod') but that gives an error native: Bad exported symbol: MyApp.myMethod . If I just api.export('myMethod') , then in the app code I have to call myMethod() ,

Does ADL work for the global namespace?

╄→гoц情女王★ 提交于 2019-12-12 12:25:26
问题 Examples such as enabling outputting of std types explain how ADL can be used to "inject" a certain function/operator, depending on the type the fn/op is applied to. I was wondering wheter ADL fully applies to the global namespace, that is, whether a type declared (or made available via using ) at global namespace scope makes ADL look for matching functions in the global namespace? Specifically, are these equivalent wrt. ADL?: // 1 - at global namespace scope struct GlobalType {}; template<

How to force a C# root namespace throughout project files for when none is coded?

半世苍凉 提交于 2019-12-12 12:12:40
问题 I want to force a root namespace on the contents of any .cs source files that don't have their contents wrapped in an explicit namespace . In other words I want to keep classes and other namespace-level structures out of the default namespace. (Working inside a Windows .NET environment with Visual Studio) In the following example, I want to force the Car class into the MotorIndustry namespace by default even though it has no explicit namespace coded. Vehicle.cs (has namespace) namespace

Enforce Global Namespace in XAML

房东的猫 提交于 2019-12-11 02:44:46
问题 In XAML, a custom namespace can be imported with an xmlns directive: xmlns:custom="clr-namespace:GreatStuff" In C#, that namespace can be imported with using GreatStuff; Moreover, evaluation of that namespace based on the global (root) namespace can be enforced as follows: using global::GreatStuff; How can I enforce evaluation based on the global namespace in XAML? Background: I am facing the (admittedly slightly obscure) situation that there is such a namespace global::GreatStuff , which

How can I export from a Meteor package into my app's namespace?

旧城冷巷雨未停 提交于 2019-12-03 03:31:19
I know how to write Meteor packages but I can't seem to figure out how to have all exports land in my app's namespace, as described in this presentation . This particular package is specific to an app I'm building, and it exports only one method that can be regarded as a decorator on the app's singleton. I tried api.export('MyApp.myMethod') but that gives an error native: Bad exported symbol: MyApp.myMethod . If I just api.export('myMethod') , then in the app code I have to call myMethod() , and that's not namespaced. Does Meteor have a mechanism similar to Node's var http = require('http'); ?

PHP Global namespace aliases

给你一囗甜甜゛ 提交于 2019-12-02 05:20:49
Here is the scenario. I am implementing namespaces into my projects. I have my own custom bridge library that calls other libraries like Zend to do the heavy lifting. I have no problem using fully qualified namespaces in my custom bridge library but would like to keep the code as terse as possible in my controllers, models and view. Here is an example of some aliasses i would like to use: use BridgeLibName\Stdlib\Arrays as arr; use BridgeLibName\Stdlib\Objects as obj; use BridgeLibName\Stdlib\Strings as str; use BridgeLibName\Stdlib\Numbers as num; use BridgeLibName\Stdlib\File as file; etc...

python: NameError:global name '…‘ is not defined [duplicate]

三世轮回 提交于 2019-11-27 01:14:27
问题 This question already has an answer here: Python: NameError: global name 'foobar' is not defined [duplicate] 1 answer in my code, I have: class A: def a(): ...... def b(): a() ...... b() Then the compiler will say "NameError: global name a() is not defined." If I pull all the stuffs out of the class A, it would be no problem, but how can I define the method in class A? Thank you very much. 回答1: You need to call self.a() to invoke a from b . a is not a global function, it is a method on the