Comments (5)
The code in question:
roscpp_core/rostime/include/ros/time.h
Lines 65 to 69 in a3f26d8
The code base uses WIN32
in many places to check for Windows. That is afaik the recommended approach. I am not sure why that is not defined in your case.
Maybe @kejxu can comment on this?
from roscpp_core.
Thanks for sharing your experience @marcbertola, and redirection @dirk-thomas!
This is a good catch, VS compiler only defines _WIN32
; however, we have never noticed build breaks resulting from this. Quick question for @marcbertola, how are you building the application? Are you building with catkin
/cmake
?
I dug in a bit into the code base, and exactly as you mentioned, WIN32
is defined in <windows.h>
:
// minwindef.h
#ifndef WIN32
#define WIN32
#endif
whereas the VS compiler only specifies _WIN32
. This is also the reason why our recent port have only been using _WIN32
(for example, 11db0ec)
from roscpp_core.
Hi @kejxu, thanks for looking into this.
I was writing a standalone program to characterize the throughput for a large PointCloud2 through ROS topics. It was a simple console program using standard, portable C++. It created a PointCloud2 message, populated it, and then sent it out repeatedly. I then used one of the standard ROS utilities (can't remember which one) to receive the messages and display the rate at which they were being received. To answer your question: I wasn't building ROS itself or using catkin.
Since I didn't actually need any of the Windows API to do this (just standard C++), I didn't include windows.h, and so WIN32 was not defined. My own research corroborates what you are saying about WIN32 vs _WIN32. When I did include it before including the ROS headers, WIN32 was defined and things started working.
Also, I haven't tried it, it's probably worth checking to see if if either variable is defined if you try compiling with GCC under Cygwin or MinGW. But then again, time.h might actually exist in those scenarios, so it might already be ok.
from roscpp_core.
Assuming that #110 checking for _WIN32
resolved this I am going ahead and close the ticket. Please feel free to continue commenting and the ticket can be reopened if necessary.
from roscpp_core.
I wasn't building ROS itself or using catkin.
Thanks! I wouldn't be able to make any assertive conclusions without further investigation, but I had very similar questions when I just started working with catkin
. A few of these macros, WIN32
and _WINDOWS
for example, I think are injected by catkin
's cmake pipeline.
If time allows, I think it would be worthwhile to try building the application with catkin
.
Since I didn't actually need any of the Windows API to do this (just standard C++), I didn't include windows.h, and so WIN32 was not defined. My own research corroborates what you are saying about WIN32 vs _WIN32. When I did include it before including the ROS headers, WIN32 was defined and things started working.
You're definitely doing the right thing not including windows.h
=)
Also, I haven't tried it, it's probably worth checking to see if if either variable is defined if you try compiling with GCC under Cygwin or MinGW. But then again, time.h might actually exist in those scenarios, so it might already be ok.
This is a very interesting point. I have not had too much experience working with GCC on Windows, but based on what I have read about, _WIN32
might need to be injected from the command line during build time. However, at this point I think we are only targeting MSVC for the win32 platform. But still, this is still a very valid point, thanks for pointing it out!
from roscpp_core.
Related Issues (20)
- ros::TimeBase: undefined behaviour for large doubles HOT 2
- command-line error:invalid macro definition: = HOT 4
- -Wconversion warnings in melodic HOT 9
- Helper for constructing time in mili/microseconds? HOT 6
- Integrating with OSS-Fuzz HOT 4
- ros::Time and ros::Duration don't respect TIME_MAX and DURATION_MAX in arethmetic operators HOT 3
- Compile errors with gcc-10 and -std=gnu++2a option HOT 2
- Conversion from size_t to uint32_t in vector serialization HOT 3
- ros::Rate::sleep is not working as expected when the rate is larger than the publish rate of /clock HOT 2
- LICENSE for v0.6.11 HOT 2
- serialization of service response message when response was failed HOT 6
- ros serialization get wrong message size when compile on arm64 with gcc -O3 HOT 4
- inclusion of unecessary boost from ros console and ros time HOT 2
- Resolution of ros::Duration::sleep() limited by implicit sleep in nanoseconds HOT 6
- Buildroot: when building cpp_common: `CMake Error at FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Boost (missing: thread) (found version "1.80.0")` HOT 2
- improper implementation of ros::Time::useSystemTime() HOT 3
- Durations not printing out properly HOT 5
- Misaligned address for type 'double', in serialization.h, causing runtime error. HOT 7
- Possible data races in the turtlesim node, detected by ThreadSanitizer HOT 1
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 roscpp_core.