shui-构造函数

原作者网址:https://www.2cto.com/kf/201402/281841.html

 

在JavaScript中,创建对象的方式包括两种:
  对象字面量
  使用new表达式

对象字面量是一种灵活方便的书写方式,例如:
  var o1 = {
    p:”I’m in Object literal”,
    alertP:function(){
      alert(this.p);
    }
  }
这样,就用对象字面量创建了一个对象o1,它具有一个成员变量p以及一个成员方法alertP。这种写法不需要定义构造函数,因此不在本文的讨论范围之内。这种写法的缺点是,每创建一个新的对象都需要写出完整的定义语句,不便于创建大量相同类型的对象,不利于使用继承等高级特性。

new表达式是配合构造函数使用的,例如new String(“a string”),调用内置的String函数构造了一个字符串对象。下面我们用构造函数的方式来重新创建一个实现同样功能的对象,首先是定义构造函数,然后是调用new表达式:
  function CO(){
    this.p = “I’m in constructed object”;
    this.alertP = function(){
      alert(this.p);
    }
  }
var o2 = newCO();
那么,在使用new操作符来调用一个构造函数的时候,发生了什么呢?其实很简单,就发生了四件事:
var obj ={};
obj.__proto__ = CO.prototype;
CO.call(obj);
return obj;
第一行,创建一个空对象obj。

第二行,将这个空对象的__proto__成员指向了构造函数对象的prototype成员对象,这是最关键的一步,具体细节将在下文描述。

第三行,将构造函数的作用域赋给新对象,因此CA函数中的this指向新对象obj,然后再调用CO函数。于是我们就给obj对象赋值了一个成员变量p,这个成员变量的值是” I’min constructed object”。

第四行,返回新对象obj。当构造函数里包含返回语句时情况比较特殊,这种情况会在下文中说到。


正确定义JavaScript构造函数

不同于其它的主流编程语言,JavaScript的构造函数并不是作为类的一个特定方法存在的;当任意一个普通函数用于创建一类对象时,它就被称作构造函数,或构造器。一个函数要作为一个真正意义上的构造函数,需要满足下列条件:

1、 在函数内部对新对象(this)的属性进行设置,通常是添加属性和方法。

2、 构造函数可以包含返回语句(不推荐),但返回值必须是this,或者其它非对象类型的值。

上文定义的构造函数CO就是一个标准的、简单的构造函数。下面例子定义的函数C1返回了一个对象,我们可以使用new表达式来调用它,该表达式可以正确返回一个对象:
  function C1(){
    var o = {
      p:”I’m p in C1”
    }
    return o;
  }
  var o1 = new C1();
  alert(o1.p);//I’m p in C1
但这种方式并不是值得推荐的方式,因为对象o1的原型是函数C1内部定义的对象o的原型,也就是Object.prototype。这种方式相当于执行了正常new表达式的前三步,而在第四步的时候返回了C1函数的返回值。该方式同样不便于创建大量相同类型的对象,不利于使用继承等高级特性,并且容易造成混乱,应该摒弃。

一个构造函数在某些情况下完全可以作为普通的功能函数来使用,这是JavaScript灵活性的一个体现。下例定义的C2就是一个“多用途”函数:
  function C2(a, b){
    this.p = a + b;
    this.alertP = function(){
      alert(this.p);
    }
    return this.p;//此返回语句在C2作为构造函数时没有意义
  }
  var c2 = new C2(2,3);
  c2.alertP();//结果为5
  alert(C2(2, 3)); //结果为5
该函数既可以用作构造函数来构造一个对象,也可以作为普通的函数来使用。用作普通函数时,它接收两个参数,并返回两者的相加的结果。为了代码的可读性和可维护性,建议作为构造函数的函数不要掺杂除构造作用以外的代码;同样的,一般的功能函数也不要用作构造对象。


为什么要使用构造函数

根据上文的定义,在表面上看来,构造函数似乎只是对一个新创建的对象进行初始化,增加一些成员变量和方法;然而构造函数的作用远不止这些。为了说明使用构造函数的意义,我们先来回顾一下前文提到的例子。执行var o2 = new CO();创建对象的时候,发生了四件事情:
var obj ={};
obj.__proto__ = CO.prototype;
CO.call(obj);
return obj;
我们说最重要的是第二步,将新生成的对象的__prop__属性赋值为构造函数的prototype属性,使得通过构造函数创建的所有对象可以共享相同的原型。这意味着同一个构造函数创建的所有对象都继承自一个相同的对象,因此它们都是同一个类的对象。关于原型(prototype)和继承的细节,笔者会再另一篇文章中深入说明。

在JavaScript标准中,并没有__prop__这个属性,不过它现在已经是一些主流的JavaScript执行环境默认的一个标准属性,用于指向构造函数的原型。该属性是默认不可见的,而且在各执行环境中实现的细节不尽相同,例如IE浏览器中不存在该属性。我们只要知道JavaScript对象内部存在指向构造函数原型的指针就可以了,这个指针是在调用new表达式的时候自动赋值的,并且我们不应该去修改它。

在构造对象的四个步骤中,我们可以看到,除第二步以外,别的步骤我们无须借助new表达式去实现,因此new表达式不仅仅是对这四个步骤的简化,也是要实现继承的必经之路。


容易混淆的地方

关于JavaScript的构造函数,有一个容易混淆的地方,那就是原型的constructor属性。在JavaScript中,每一个函数都有默认的原型对象属性prototype,该对象默认包含了两个成员属性:constructor和__proto__。关于原型的细节就不在本文赘述了,我们现在关心的是这个constructor属性。

按照面向对象的习惯性思维,我们说构造函数相当于“类”的定义,从而可能会认为constructor属性就是该类实际意义上的构造函数,在new表达式创建一个对象的时候,会直接调用constructor来初始化对象,那就大错特错了。new表达式执行的实际过程已经在上文中介绍过了(四个步骤),其中用于初始化对象的是第三步,调用的初始化函数正是“类函数”本身,而不是constructor。如果没有考虑过这个问题,这一点可能不太好理解,那就让我们举个例子来说明一下吧:
  function C3(a, b){
    this.p = a + b;
    this.alertP = function(){
      alert(this.p);
    }
   }
//我们定义一个函数来覆盖C3原型中的constructor,试图改变属性p的值
   function fake(){
    this.p = 100;
   }
   C3.prototype.constructor = fake; //覆盖C3原型中的constructor
   var c3 = new C3(2,3);
   c3.alertP();//结果仍然为5
上述代码手动改变了C3原型中的constructor函数,然而却没有对c3对象的创建产生实质的影响,可见在new表达式中,起初始化对象作用的只能是构造函数本身。那么constructor属性的作用是什么呢?一般来说,我们可以使用constructor属性来测试对象的类型:
var myArray = [1,2,3];
(myArray.constructor == Array); // true
这招对于简单的对象是管用的,涉及到继承或者跨窗口等复杂情况时,可能就没那么灵光了:
function f() { this.foo = 1;}
function s() { this.bar = 2; }
s.prototype = new f(); // s继承自f

var son = new s(); // 用构造函数s创建一个子类对象
(son.constructor == s); // false
(son.constructor == f); // true
这样的结果可能跟你的预期不相一致,所以使用constructor属性的时候一定要小心,或者干脆不要用它。

转载于:https://www.cnblogs.com/xiaoyangtian/p/7929277.html

-------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-000-addr=192.168.1.27;_running=0 2025-10-03 10:43:29.019 [24138] LOG_DEBUG modbus_tcp connect 192.168.1.27:502 start... 2025-10-03 10:43:29.020 [24138] LOG_INFO modbus_tcp serveraddr is ip format -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 2025-10-03 10:43:29.238 [24140] LOG_DEBUG 192.168.1.27:502: tcp connect suc: 2025-10-03 10:43:29.238 [24140] LOG_INFO 192.168.1.27:502: tcp start rec data -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-000-addr=192.168.1.27;ret=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ModbusTCPClient::connect() conn-111-addr=192.168.1.27;_process_thread=1 [2025-10-03 10:43:30] ModbusTCPInput::start conn_status: 3;collect_status:2;_running:1;_poll_thread:1 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 MQTT connecting -222- to tcp://192.168.1.27:1883 with _connected 0 -------------------------------------- Failed to start output processor -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 MQTT connecting -222- to tcp://192.168.1.27:1883 with _connected 0 Failed to start output processor GatewayManager::start()00: 1 Gateway manager started. Press Ctrl+C or Ctrl+Z to stop. -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 [2025-10-03 10:43:32] Initialized upload,logs and download directories [2025-10-03 10:43:32] Server started on port :8082 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 get- pathMoudle: collectconn collectconn:in Database opened: ./jcdz-db.db -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=1 ----------id=1;address=2 ---------id=1;value=0 --input.id=1;data_point.size()=1 ====================================== SQL sql=:SELECT CollectConnNO, Name,ConnType,ProtocolType, Path,DnsIP,Port,Timeout,Memo,ConnStatus,ConnTime,CollectStatus,CollectTime,ChanCount,ComName,ComBaudRate,ComParityCheck,ComStopBit,RegDevName,RegDevId,RegMode,RegFactType,RegFactChan,RegFactNO FROM IOT_CollectConn_info; -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 [2025-10-03 10:43:35] GET /api/collectconn - Status: 200 - Remote: 192.168.20.27:61079 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 -------------------------------------- -------data_points.size()=1 ModbusTCPInput::pollData() conn-id=1;dp.id=1;elapsed=0 get- pathMoudle: collectconn collectconn:in stop ----: conn [2025-10-03 10:43:36] ModbusTCPInput::stop conn_status: 0;collect_status:5;_running:1;_poll_thread:1 ==24138== Thread 14: ==24138== Conditional jump or move depends on uninitialised value(s) ==24138== at 0x25B4A3: JCNetopTcpclient::Stop() (JCNetopTcpclient.cpp:293) ==24138== by 0x2466FF: ModbusTCPClient::disconnect() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x162DC3: ModbusTCPInput::stop() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168BF7: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== Uninitialised value was created by a heap allocation ==24138== at 0x4849013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x24608E: ModbusTCPClient::ModbusTCPClient(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16249E: ModbusTCPInput::ModbusTCPInput(InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x183FC0: void __gnu_cxx::new_allocator<ModbusTCPInput>::construct<ModbusTCPInput, InputConfig&>(ModbusTCPInput*, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x182F5D: void std::allocator_traits<std::allocator<ModbusTCPInput> >::construct<ModbusTCPInput, InputConfig&>(std::allocator<ModbusTCPInput>&, ModbusTCPInput*, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1817A7: std::_Sp_counted_ptr_inplace<ModbusTCPInput, std::allocator<ModbusTCPInput>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<InputConfig&>(std::allocator<ModbusTCPInput>, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17F945: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<ModbusTCPInput, std::allocator<ModbusTCPInput>, InputConfig&>(ModbusTCPInput*&, std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17DD45: std::__shared_ptr<ModbusTCPInput, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<ModbusTCPInput>, InputConfig&>(std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x17BA86: std::shared_ptr<ModbusTCPInput>::shared_ptr<std::allocator<ModbusTCPInput>, InputConfig&>(std::_Sp_alloc_shared_tag<std::allocator<ModbusTCPInput> >, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x178230: std::shared_ptr<ModbusTCPInput> std::allocate_shared<ModbusTCPInput, std::allocator<ModbusTCPInput>, InputConfig&>(std::allocator<ModbusTCPInput> const&, InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174553: std::shared_ptr<ModbusTCPInput> std::make_shared<ModbusTCPInput, InputConfig&>(InputConfig&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x169B98: GatewayManager::createProcessors(std::vector<GatewayConfig, std::allocator<GatewayConfig> >&, bool) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== Invalid read of size 8 ==24138== at 0x145344: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::size() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174BED: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::vector(std::vector<GatewayConfig, std::allocator<GatewayConfig> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16A073: GatewayManager::getGateways() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168C18: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== Address 0xa0 is not stack'd, malloc'd or (recently) free'd ==24138== ==24138== ==24138== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==24138== Access not within mapped region at address 0xA0 ==24138== at 0x145344: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::size() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x174BED: std::vector<GatewayConfig, std::allocator<GatewayConfig> >::vector(std::vector<GatewayConfig, std::allocator<GatewayConfig> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x16A073: GatewayManager::getGateways() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168C18: GatewayManager::stopInputProcessors(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1B1868: CollectConn::get[abi:cxx11](httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x18F56A: handle_get(httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2145B0: void std::__invoke_impl<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(std::__invoke_other, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x206BBE: std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&> >::value, void>::type std::__invoke_r<void, void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&>(void (*&)(httplib::Request const&, httplib::Response&), httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F38D2: std::_Function_handler<void (httplib::Request const&, httplib::Response&), void (*)(httplib::Request const&, httplib::Response&)>::_M_invoke(std::_Any_data const&, httplib::Request const&, httplib::Response&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DF3FA: std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A18B8: httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >, std::function<void (httplib::Request const&, httplib::Response&)> > > > const&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1A15AA: httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== If you believe this happened as a result of a stack ==24138== overflow in your program's main thread (unlikely but ==24138== possible), you can try to increase the size of the ==24138== main thread stack using the --main-stacksize= flag. ==24138== The main thread stack size used in this run was 8388608. ==24138== ==24138== HEAP SUMMARY: ==24138== in use at exit: 485,052 bytes in 1,234 blocks ==24138== total heap usage: 3,183 allocs, 1,949 frees, 799,663 bytes allocated ==24138== ==24138== Thread 1: ==24138== 304 bytes in 1 blocks are possibly lost in loss record 403 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x26BC48: zsummer::log4z::ThreadHelper::start() (log4z.cpp:1145) ==24138== by 0x26D5CE: zsummer::log4z::LogerManager::start() (log4z.cpp:1490) ==24138== by 0x268BF0: JCCommuLib::JCCommuLib() (JCCommuLib.cpp:34) ==24138== by 0x268ECB: JCCommuLib::getInstance() (JCCommuLib.cpp:67) ==24138== by 0x19142B: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 404 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x2697F3: std::thread::thread<void (JCCommuLib::*)(), JCCommuLib*, void>(void (JCCommuLib::*&&)(), JCCommuLib*&&) (std_thread.h:143) ==24138== by 0x26950A: JCCommuLib::Run() (JCCommuLib.cpp:106) ==24138== by 0x191455: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 405 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4AD526D: Paho_thread_start (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x4AB8F14: MQTTAsync_connect (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x24FCAF: MQTTClientWrapper::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x167AB5: MQTTOutput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1683DE: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 406 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4AD526D: Paho_thread_start (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x4AB8F4A: MQTTAsync_connect (in /usr/local/lib/libpaho-mqtt3a.so.1.3.15) ==24138== by 0x24FCAF: MQTTClientWrapper::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x167AB5: MQTTOutput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1683DE: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 304 bytes in 1 blocks are possibly lost in loss record 407 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x173E3D: std::thread::thread<void (GatewayManager::*)(), GatewayManager*, void>(void (GatewayManager::*&&)(), GatewayManager*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1684B0: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 608 bytes in 2 blocks are possibly lost in loss record 472 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x17202D: std::thread::thread<void (ModbusTCPInput::*)(), ModbusTCPInput*, void>(void (ModbusTCPInput::*&&)(), ModbusTCPInput*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x162682: ModbusTCPInput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168330: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 608 bytes in 2 blocks are possibly lost in loss record 473 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x24731D: std::thread::thread<void (ModbusTCPClient::*)(), ModbusTCPClient*, void>(void (ModbusTCPClient::*&&)(), ModbusTCPClient*&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x2464FE: ModbusTCPClient::connect() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1626C9: ModbusTCPInput::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x168330: GatewayManager::start() (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x191529: main (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 1,520 bytes in 5 blocks are possibly lost in loss record 544 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x206F09: std::thread::thread<httplib::ThreadPool::worker, , void>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F3D40: void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, httplib::ThreadPool::worker>(std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8DAE: void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, httplib::ThreadPool::worker>(std::allocator<std::thread>&, std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8EC9: void std::vector<std::thread, std::allocator<std::thread> >::_M_realloc_insert<httplib::ThreadPool::worker>(__gnu_cxx::__normal_iterator<std::thread*, std::vector<std::thread, std::allocator<std::thread> > >, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DB9FD: void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1968F9: httplib::ThreadPool::ThreadPool(unsigned long) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x19DB2D: httplib::Server::Server()::{lambda()#1}::operator()() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x208603: httplib::ThreadPool* std::__invoke_impl<httplib::ThreadPool*, httplib::Server::Server()::{lambda()#1}&>(std::__invoke_other, httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== 3,040 bytes in 10 blocks are possibly lost in loss record 549 of 561 ==24138== at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==24138== by 0x40147D9: calloc (rtld-malloc.h:44) ==24138== by 0x40147D9: allocate_dtv (dl-tls.c:375) ==24138== by 0x40147D9: _dl_allocate_tls (dl-tls.c:634) ==24138== by 0x4E657B4: allocate_stack (allocatestack.c:430) ==24138== by 0x4E657B4: pthread_create@@GLIBC_2.34 (pthread_create.c:647) ==24138== by 0x4C5E328: std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30) ==24138== by 0x206F09: std::thread::thread<httplib::ThreadPool::worker, , void>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F3D40: void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, httplib::ThreadPool::worker>(std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1E8DAE: void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, httplib::ThreadPool::worker>(std::allocator<std::thread>&, std::thread*, httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1DB9B7: void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1968F9: httplib::ThreadPool::ThreadPool(unsigned long) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x19DB2D: httplib::Server::Server()::{lambda()#1}::operator()() const (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x208603: httplib::ThreadPool* std::__invoke_impl<httplib::ThreadPool*, httplib::Server::Server()::{lambda()#1}&>(std::__invoke_other, httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== by 0x1F6A4D: std::enable_if<std::__and_<std::__not_<std::is_void<httplib::TaskQueue*> >, std::is_convertible<std::__invoke_result<httplib::Server::Server()::{lambda()#1}&>::type, httplib::TaskQueue*> >::value, httplib::TaskQueue*>::type std::__invoke_r<httplib::TaskQueue*, httplib::Server::Server()::{lambda()#1}&>(httplib::Server::Server()::{lambda()#1}&) (in /home/sxp/shui/jcdzarm/webserver/main-new) ==24138== ==24138== LEAK SUMMARY: ==24138== definitely lost: 0 bytes in 0 blocks ==24138== indirectly lost: 0 bytes in 0 blocks ==24138== possibly lost: 7,296 bytes in 24 blocks ==24138== still reachable: 477,756 bytes in 1,210 blocks ==24138== of which reachable via heuristic: ==24138== length64 : 119,744 bytes in 438 blocks ==24138== suppressed: 0 bytes in 0 blocks ==24138== Reachable blocks (those to which a pointer was found) are not shown. ==24138== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==24138== ==24138== For lists of detected and suppressed errors, rerun with: -s ==24138== ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 0 from 0) Segmentation fault
10-04
P11093核桃之星2 标准IO 传统题 来源 姜饼 时间限制 1000ms 内存限制 256MB 题目描述 晚会开场时,面条老师给大家激情唱跳了一首《核桃之星》,点燃了全场的气氛。 老师们跟着歌词的节奏挥手。如果尾字押韵,在每句歌词的结尾时,老师们还会情不自禁地鼓一次掌。 比如,当面条老师唱到“天空闪耀伤痛,霓虹映不出面容,菜市场里卖的鱼,徒留冰冷的心胸”四句时,句尾 tong rong xiong 三次押 ong 韵,所以老师们会鼓三次掌。 现在给出他唱的歌词拼音,和对应的韵脚,请你统计老师们一共鼓了几次掌。 附韵母表:a o e i u ü ai ei ui ao ou iu ie üe er an en in un ün ang eng ing ong。 数据保证对应的韵脚以及歌词结尾押韵中不存在和 u ü 有关的韵脚,例如 u ü ui ou iu üe un ün。即仅会测试 a o e i ai ei ao ie er an en in ang eng ing ong。 在本题中,押韵要求结尾韵母和韵脚完全相同,shuai 不押 i 韵,keng 不押 ing 韵。 输入格式 第一行一个整数 � n,表示会有几句歌词。 第二行一个字符串,表示这首歌的韵脚。保证韵脚中不会存在 u ü ou iu üe un ün 第 3 ∼ � + 2 3∼n+2 行每行一个字符串,表示每句歌词的拼音,字与字之间用连字符 - 分隔。 数据保证对应的韵脚以及每句歌词结尾押韵中不存在和 u ü 有关的韵脚,例如 u ü ui ou iu üe un ün。 输出格式 一行一个整数,代表老师鼓掌们的次数。 input1 复制 4 ong tian-kong-shan-yao-shang-tong ni-hong-ying-bu-chu-mian-rong cai-shi-chang-li-mai-de-ying tu-liu-bing-leng-de-xin-xiong output1 复制 3 input2 复制 4 i kun-zai-ri-fu-yi-ri-xun-huan-de-gui-ji xi-wang-shi-bo-li-guan-di-de-shui-di ye-wan-de-feng-na-me-zi-yi-na-me-mei hua-guo-zhi-jian-que-yong-yuan-wu-fa-chu-ji output2 复制 3 样例解释 #2 注意,mei 是 ei 韵,不属于 i 韵。 数据范围与约定 对于 100 % 100% 的数据, 1 ≤ � ≤ 1000 1≤n≤1000 ,每行字符串长度不超过 100 100 ,保证符合拼音法,句尾没有多余空格。 注意,本题是 windows 下出的数据,换行符是\r\n。c++
最新发布
12-28
1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : ‘void CANopenClient::cleanupTimeoutRequests()’ is private within this context 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : 437 | cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : | ^~~~~~~~~~~~~~~~~~~~~~ 1>C:\shui\web1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : ‘void CANopenClient::cleanupTimeoutRequests()’ is private within this context 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : 437 | cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,9): error : | ^~~~~~~~~~~~~~~~~~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : declared private here 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : 112 | void cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : | ^~~~~~~~~~~~~~~~~~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : ‘void CANopenClient::cleanupTimeoutRequests()’ is private within this context 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : 437 | cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : | ~~~~~~~~~~~~~~~~~~~~~~^~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : declared private here 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : 112 | void cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : | ^~~~~~~~~~~~~~~~~~~~~~ 1>canopen_parser.cpp 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : ‘memset’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : 22 | memset(data, 0, sizeof(data)); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : | ^~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : 9 | #include <functional> 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : +++ |+#include <cstring> 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : 10 | 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : ‘memset’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : 29 | memset(data, 0, sizeof(data)); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : | ^~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): message : ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : ‘memcpy’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : 31 | memcpy(data, canData, length); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : | \comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : declared private here 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : 112 | void cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : | ^~~~~~~~~~~~~~~~~~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : ‘void CANopenClient::cleanupTimeoutRequests()’ is private within this context 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : 437 | cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_master.cpp(437,31): error : | ~~~~~~~~~~~~~~~~~~~~~~^~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : declared private here 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : 112 | void cleanupTimeoutRequests(); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_client.h(112,10): message : | ^~~~~~~~~~~~~~~~~~~~~~ 1>canopen_parser.cpp 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : ‘memset’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : 22 | memset(data, 0, sizeof(data)); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(22,13): error : | ^~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : 9 | #include <functional> 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : +++ |+#include <cstring> 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(10,1): message : 10 | 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : ‘memset’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : 29 | memset(data, 0, sizeof(data)); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): error : | ^~~~~~ 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(29,13): message : ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : ‘memcpy’ was not declared in this scope 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : 31 | memcpy(data, canData, length); 1>C:\shui\web\comm\x86\bb\aaa-demo\93-dp\11-dp\11-dp\..\..\canopen_parser.h(31,17): error : |
11-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值