06_bool类型

/*
    新增bool类型
    C++在C语言的基本类型系统之上增加了bool
    C++中的bool可取的值只有true和false
    理论上bool只占用一个字节,
    如果多个bool变量定义在一起,可能会各占一个bit,这取决于编译器的实现

    true  代表真值,  编译器内部用1来表示
    false 代表非真值,编译器内部用0来表示

    bool类型只有true(非0)和false(0)两个值
    C++编译器会在赋值时将非0值转换为true,0值转换为false

*/
#if 1
void test()
{
    int a;
    bool b = true;
    bool b1 = true;  //告诉c++编译器给我分配 1个字节的内存
    bool b2, b3, b4, b5;
    printf("b = %d, sizeof(b) = %d\n", b, sizeof(b));//b = 1, sizeof(b) = 1
    b = 4;
    a = b;
    printf("a = %d, b = %d\n", a, b);//a = 1, b = 1
    //bool变量 1 或者 0
    b1 = -10;
    cout << "bl:" << b1 << endl;//bl:1
    //bool变量 1 或者 0
    b1 = 0;
    cout << "bl:" << b1 << endl;//bl:0
}
#endif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
06/06/2023-16:31:47] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) /home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py:166: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. bool: np.bool, Traceback (most recent call last): File "/home/sniper/anaconda3/envs/labelme/bin/yolo", line 8, in <module> sys.exit(entrypoint()) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/cfg/__init__.py", line 398, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 302, in val validator(model=self.model) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/validator.py", line 114, in __call__ model = AutoBackend(model, device=self.device, dnn=self.args.dnn, data=self.args.data, fp16=self.args.half) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/nn/autobackend.py", line 174, in __init__ dtype = trt.nptype(model.get_binding_dtype(i)) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py", line 166, in nptype bool: np.bool, File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations 如何修复
06-07

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值