簡體   English   中英

Visual Studio 2010,有一些方法我可以添加一個前綴,例如(C:\\)來#include大量的 <boost/asio.hpp> 頭?

[英]Visual Studio 2010, is there some way I can add a prefix e.g. (C:\) to #include a massive amount of <boost/asio.hpp> headers?

我從在線教程中獲得了一些C ++ Boost代碼。 每個路徑都以一種格式聲明。

是否有一種方法包括Visual Studio為who項目添加一個前綴,允許我以該格式#include文件?

它是一個接一個的頭文件,它們都引用了該格式的更多頭文件。

我知道QT Creator有一個#INCLUDEPATHS選項,它允許你導入一個目錄,然后直接從那里引用。

任何幫助將非常感激。

#include <boost\asio.hpp>
using namespace boost;

class SimpleSerial
{
public:
/**
 * Constructor.
 * \param port device name, example "/dev/ttyUSB0" or "COM4"
 * \param baud_rate communication speed, example 9600 or 115200
 * \throws boost::system::system_error if cannot open the
 * serial device
 */
SimpleSerial(std::string port, unsigned int baud_rate)
: io(), serial(io,port)
{
    serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate));
}

/**
 * Write a string to the serial device.
 * \param s string to write
 * \throws boost::system::system_error on failure
 */
void writeString(std::string s)
{
    boost::asio::write(serial,boost::asio::buffer(s.c_str(),s.size()));
}

/**
 * Blocks until a line is received from the serial device.
 * Eventual '\n' or '\r\n' characters at the end of the string are removed.
 * \return a string containing the received line
 * \throws boost::system::system_error on failure
 */
std::string readLine()
{
    //Reading data char by char, code is optimized for simplicity, not speed
    using namespace boost;
    char c;
    std::string result;
    for(;;)
    {
        asio::read(serial,asio::buffer(&c,1));
        switch(c)
        {
            case '\r':
                break;
            case '\n':
                return result;
            default:
                result+=c;
        }
    }
}

private:
boost::asio::io_service io;
boost::asio::serial_port serial;
};

單擊菜單欄中的“項目”,然后選擇“屬性...”。 然后使用菜單樹轉到“Configuration Properties”/“C / C ++”/“General”並將目錄添加到“Additional Include Directories”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM