我已经正确编译了 boost 二进制文件并按照所有说明进行操作,但是我遇到了很多错误,我不知道为什么!
这是我的“包含”设置:
这是我用来测试boost的代码:
#include <boost/asio.hpp> // include boost
#include <iostream>
using namespace std;
using namespace boost::asio; // save tons of typing
// These are the values our port needs to connect
#ifdef _WIN32
// windows uses com ports, this depends on what com port your cable is plugged in to.
const char *PORT = "COM4";
#else
// *nix com ports
const char *PORT = "dev/ttyS3";
#endif
// Note: all the following except BAUD are the exact same as the default values
// what baud rate do we communicate at
serial_port_base::baud_rate BAUD(9600);
// how big is each "packet" of data (default is 8 bits)
serial_port_base::character_size CSIZE(8);
// what flow control is used (default is none)
serial_port_base::flow_control FLOW(serial_port_base::flow_control::none);
// what parity is used (default is none)
serial_port_base::parity PARITY(serial_port_base::parity::none);
// how many stop bits are used (default is one)
serial_port_base::stop_bits STOP(serial_port_base::stop_bits::one);
int main()
{
// create the I/O service that talks to the serial device
io_service io;
// create the serial device, note it takes the io service and the port name
serial_port port(io, PORT);
// go through and set all the options as we need them
// all of them are listed, but the default values work for most cases
port.set_option(BAUD);
port.set_option(CSIZE);
port.set_option(FLOW);
port.set_option(PARITY);
port.set_option(STOP);
// buffer to store commands
// this device reads 8 bits, meaning an unsigned char, as instructions
// varies with the device, check the manual first
unsigned char command[1] = { 0 };
// read in user value to be sent to device
int input;
cin >> input;
// Simple loop, since the only good values are [0,255]
// break when a negative number is entered.
// The cast will convert too big numbers into range.
while (input >= 0)
{
// convert our read in number into the target data type
command[0] = static_cast<unsigned char>(input);
// this is the command that sends the actual bits over the wire
// note it takes a stream and a asio::buffer
// the stream is our serial_port
// the buffer is constructed using our command buffer and
// the number of instructions to send
write(port, buffer(command, 1));
// read in the next input value
cin >> input;
}
// all done sending commands
return 0;
}
我的错误(我无法提供任何信息,因为我不知道是什么意思或导致它们的原因):
1 IntelliSense: identifier "WSA13" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 70 19 Test3
2 IntelliSense: identifier "WSA102" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 73 34 Test3
3 IntelliSense: identifier "WSA100" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 76 20 Test3
4 IntelliSense: identifier "WSA113" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 79 23 Test3
5 IntelliSense: identifier "WSA103" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 82 21 Test3
6 IntelliSense: identifier "WSA106" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 90 24 Test3
7 IntelliSense: identifier "WSA107" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 93 24 Test3
8 IntelliSense: identifier "WSA108" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 96 22 Test3
9 IntelliSense: identifier "WSA9" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 99 20 Test3
10 IntelliSense: identifier "WSA14" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 102 11 Test3
11 IntelliSense: identifier "WSA110" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 105 22 Test3
12 IntelliSense: identifier "WSA112" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 108 17 Test3
13 IntelliSense: identifier "WSA4" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 111 17 Test3
14 IntelliSense: identifier "WSA22" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 114 22 Test3
15 IntelliSense: identifier "WSA115" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 117 18 Test3
16 IntelliSense: identifier "WSA38" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 120 19 Test3
17 IntelliSense: identifier "WSA116" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 123 18 Test3
18 IntelliSense: identifier "WSA117" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 126 19 Test3
19 IntelliSense: identifier "WSA118" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 129 25 Test3
20 IntelliSense: identifier "WSA24" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 132 20 Test3
21 IntelliSense: identifier "WSA119" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 135 21 Test3
22 IntelliSense: identifier "WSA123" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 148 24 Test3
23 IntelliSense: identifier "WSA126" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 151 19 Test3
24 IntelliSense: identifier "WSA128" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 154 16 Test3
25 IntelliSense: identifier "WSA130" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 162 29 Test3
26 IntelliSense: identifier "WSA138" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 168 15 Test3
27 IntelliSense: identifier "WSA140" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 176 17 Test3
28 IntelliSense: identifier "WSA11001L" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 182 20 Test3
29 IntelliSense: identifier "WSA11002L" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 185 30 Test3
30 IntelliSense: identifier "WSA11004L" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 188 13 Test3
31 IntelliSense: identifier "WSA11003L" is undefined c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 191 17 Test3
32 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000002" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 66 22 Test3
33 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000001" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 67 15 Test3
34 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000004" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 68 20 Test3
35 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000008" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 69 23 Test3
36 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000800" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 70 17 Test3
37 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000100" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 71 20 Test3
38 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000400" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp 72 26 Test3
39 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 51 3 Test3
40 IntelliSense: identifier "BOOST_ASIO_OS_DEF_12" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 52 3 Test3
41 IntelliSense: identifier "BOOST_ASIO_OS_DEF_13" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 80 3 Test3
42 IntelliSense: identifier "BOOST_ASIO_OS_DEF_9" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 108 3 Test3
43 IntelliSense: identifier "BOOST_ASIO_OS_DEF_10" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 144 3 Test3
44 IntelliSense: identifier "BOOST_ASIO_OS_DEF_11" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp 181 3 Test3
45 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x0001" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\tcp.hpp 126 37 Test3
46 IntelliSense: identifier "BOOST_ASIO_OS_DEF_0" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\unicast.hpp 59 3 Test3
47 IntelliSense: identifier "BOOST_ASIO_OS_DEF_4" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\unicast.hpp 60 3 Test3
最佳答案
Known Bugs with Visual Studio 2013/Visual C++ 12
Visual Studio 2013 was released quite late in the release process, so there exist several unresolved issues. These include:
- Serialization can't compile because of a missing include.
- Using has_member_function_callable_with from Boost.Container's allocator_traits causes a compile error (#9332).
- In libraries such as Unordered and MultiIndex, calling overloaded functions with initializer lists can result in a compile error, with Visual C++ claiming that the overloads are ambiguous. This is a Visual C++ bug and it isn't clear if there's a good workaround. This won't affect code that doesn't use initializer lists, or uses an initializer list that doesn't require an implicit conversion (i.e. an initializer list of the container's exact value type).
- Thread: ex_scoped_thread compile fails (#9333).
请注意,VC++ 12 并未得到完全支持,即使 Boost 可以编译也不一定意味着它不会有运行时错误(遗憾的是,这意味着您必须为它们制定变通办法) .如果您在 Boost 中发现更多错误,be sure to report it to them .
关于c++ - Boost 1.55 不适用于 Visual Studio 2013,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20534622/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm
当我使用has_one时,它工作得很好,但在has_many上却不行。在这里您可以看到object_id不同,因为它运行了另一个SQL来再次获取它。ruby-1.9.2-p290:001>e=Employee.create(name:'rafael',active:false)ruby-1.9.2-p290:002>b=Badge.create(number:1,employee:e)ruby-1.9.2-p290:003>a=Address.create(street:"123MarketSt",city:"SanDiego",employee:e)ruby-1.9.2-p290
如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:
我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我
我正在使用带有Rails的Devise,我想添加一个方法“getAllComments”,所以我这样写:classUser在我的Controller中:defdashboard@user=current_user@comments=@user.getAllComments();end当我访问我的url时,我得到了undefinedmethod`getAllComments'for#我做错了什么?谢谢 最佳答案 因为getAllComments是一个类方法,而您正试图将其作为实例方法访问。您要么需要访问它:User.getAllCom
我正在使用Rails3.2.3和Ruby1.9.3p0。我发现我经常需要确定某个字符串是否出现在选项列表中。看来我可以使用Ruby数组.includemethod:或正则表达式equals-tildematchshorthand用竖线分隔选项:就性能而言,一个比另一个好吗?还有更好的方法吗? 最佳答案 总结:Array#include?包含String元素,在接受和拒绝输入时均胜出,对于您的示例只有三个可接受的值。对于要检查的更大的集合,看起来Set#include?和String元素可能会获胜。如何测试我们应该根据经验对此进行测试
我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“
有没有办法让Ruby能够做这样的事情?classPlane@moved=0@x=0defx+=(v)#thisiserror@x+=v@moved+=1enddefto_s"moved#{@moved}times,currentxis#{@x}"endendplane=Plane.newplane.x+=5plane.x+=10putsplane.to_s#moved2times,currentxis15 最佳答案 您不能在Ruby中覆盖复合赋值运算符。任务在内部处理。您应该覆盖+,而不是+=。plane.a+=b与plane.a=