Comments (5)
First I'm a fan of removing macros when they can be replaced by C++ standards. I guess my issue isn't so much with the shadowing, more of the use of macros. Shadowing may be allowed, but imho if it can be avoided it should be.
Here's a sample function I'm proposing:
template<class ... Args>
inline void infoLog(Args ... args)
{
std::lock_guard<std::mutex> lock{::Fastcgipp::Logging::mutex};
::Fastcgipp::Logging::header(::Fastcgipp::Logging::INFO);
int dummy[] = { (*::Fastcgipp::Logging::logstream << args, 0)... };
*::Fastcgipp::Logging::logstream << std::endl;
}
This performs all args operations on logstream and then does an endl.
from fastcgipp.
Hmmmm. As it sits now I'm not convinced of any reason why shadowing in this situation is actually a problem. Isn't shadowing fully permitted in the C++ standard? Why do you feel shadowing should be disallowed?
from fastcgipp.
Shadowing can cause really hard to find bugs. If comes from Macro expansion then it is even harder. I agree with @Erroneous1 suggested changes.
from fastcgipp.
Hmmmm. You know. I must admit that I really do prefer the variadic template solution to my macros. That is the way it should have been done to begin with. That being said, I'm not willing to break all the code that's been written so far by changing the interface. This isn't an alpha stage; it's a beta stage and that means sticking with these kind of design choices even when they are shown to be less ideologically sound. Certainly in the next major version change, your solution will be preferred.
Beyond all of that, can anyone present me with a hypothetical situation where this shadowing would lead to a bug? Just for discussions sake.
from fastcgipp.
I can't think of a particular situation where shadowing would cause a bug when used in a matter like this. Generally though if you are expecting a variable named X to be of type Y and you declare X as Z that could be an issue. Or if you declare X as Y twice and expect X outside of the scope you declared it the second time to still be what it was inside the scope.
A quick and easy mitigation would be to use a unique name for the lock_guard like fastcgipp_fail_log_lock. That would give you time to consider how you would like to replace the macros.
Another possible implementation would be to make a class that contains a lock_guard and a reference/pointer to an ostream that passes ostream& operator<< to that reference. FAIL_LOG's std::exit is the only reason why you might not want to do that.
from fastcgipp.
Related Issues (20)
- [failed build example]try use c++20 modules for compile my example
- Support the Meson build system. HOT 1
- Prevent GCC warnings
- Sould not register signal handlers HOT 3
- how to make a json response? HOT 1
- Windows systems not supported??? HOT 1
- 3.1 Release HOT 1
- undefined reference to pthread, for examples HOT 3
- error: ‘Fastcgipp::Http::RequestMethod’ is not a class or namespace
- Are you accepting pull requests? HOT 3
- tests/curl.cpp cannot POST data to another website HOT 7
- Overview of logging mechanism
- fastcgipp and proxy HOT 1
- CMake PostgreSQL missing required version number HOT 4
- io_uring support? HOT 2
- postgres pipline query HOT 1
- Raspberry Pi with nginx: Echo example gives 413 Request Entity Too Large on form submit HOT 4
- Permission not being set on unix socket according to permission parameter in listen() call. HOT 2
- Error during compilation on Ubuntu 16.04, g++ 5.4 HOT 2
- Missing virtual destructor in Curl_base HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastcgipp.