ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As pointed out elsewhere, this is a C/C++ question rather than a ROS question. The difference between the two styles of #include specify different directory search strategies:

  • Using angle brackets (#include <iostream>) asks the C/C++ preprocessor to look for the given path only in directories in the configured include search path. (In particular, the current directory is not searched.)
  • Using double quotes (#include "iostream") asks the C/C++ preprocessor to look for the given path relative to the current directory and then try directories in the configured include search path. The standards are specific about this, so you can think of using double-quotes as searching a superset of locations.

The default include search path is set by the compiler, and can be altered by environment variables or command-line options (-I, for example). The C/C++ standards use more vague phrasing like "an implementation-defined manner" for the include search path. See your compiler's documentation for specifics. The default include search path differs, typically, between C and C++ compiles. (So using g++ rather than gcc on the command line will give different results, for example.)

It's conventional to use angle brackets for includes provided by the system or libraries and double-quotes for your source code. (But the distinction between "your source" and "libraries" also depends on how you've set up your project.) It seems to me more conventional to use #include <ros/ros.h> rather than double-quotes.