C++——Function Style Cast 有歧义

#include <iostream>#include <string>using namespace std; struct Print { template<typename T> Print(T t){ cout<<(t+=10); } }; struct S { S(int a){ cout << a << endl; }; }; void foo(double a) { S w(int(a)); // function declaration // S x(int()); // function declaration S y((int(a))); // object declaration S yy((int)a); // object declaration S z = int(a); // object declaration } template <class T> struct X {}; template <int N> struct Y {}; X<int()> a; // type-id X<int(1)> b; // expression (ill-formed) Y<int()> c; // type-id (ill-formed) Y<int(1)> d; // expression void foo(signed char a) { sizeof(int()); // type-id (ill-formed) sizeof(int(a)); // expression sizeof(int(unsigned(a))); // type-id (ill-formed) (int())+1; // type-id (ill-formed) (int(a))+1; // expression (int(unsigned(a)))+1; // type-id (ill-formed) } int main() { // 这句为什么是一句函数声明而不是变量创建? double a = 3....

February 21, 2024 · 1 min · Rick Cui

Ubuntu 升级 GCC 版本

GCC 源码网址 https://ftp.gnu.org/gnu/gcc/ 源码安装参考这里 添加相应的源 sudo add-apt-repository ppa:ubuntu-toolchain-r/test 如果提示 add-apt-repository: command not found,需要安装 sudo apt-get install software-properties-common 更新软件源 sudo apt-get update 安装指定版本的 gcc sudo apt-get install gcc-9 查看 gcc find / -name "gcc*" dpkg -l | grep gcc 指定默认使用的 gcc 版本 通过 update-alternatives 建立文件关联,如果安装了同一个软件的不同版本,可以使用 update-alternatives 命令设置默认使用哪个 首先要让系统知道我们安装了多个版本的 gcc # 命令最后的 20 和 50 是优先级,如果使用 auto 选择模式,系统将默认使用优先级高的 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50 查看 gcc 版本...

January 8, 2024 · 1 min · Rick Cui

Windows Cmd 设置临时和永久环境变量

打开 cmd 命令提示符(Win11) 查看所有环境变量:输入 set 查看 path:输入 set path 设置临时环境变量:set path=D:\Work\dem\Python39;%PATH% 设置永久环境变量:setx path=D:\Work\dem\Python39;%PATH%

January 5, 2024 · 1 min · Rick Cui

Python Conda GDAL 环境搭建

安装 miniconda,conda 命令使用可参考这里; 注意: 安装包的时候,conda install 和 pip install 最好不要混用,优先使用 pip 查看 python 包路径 python -m site 安装 GDAL 通过命令 pip install gdal 安装一般会报错,推荐下载 whl 安装包进行安装,可从这里下载 import gdal from osgeo import gdal 报错 在 python 安装各种环境包的文件夹下,如:D:**\python3.9.12\Lib\site-packages\ 文件夹下,新建 gdal.py 文件,将以下代码复制进去: # import osgeo.gdal as a convenience from osgeo.gdal import deprecation_warn deprecation_warn('gdal') from osgeo.gdal import * 参考: GDAL 安装教程(Python) 解决 import gdal 导入失败的问题,但 from osgeo import gdal 导入成功

January 4, 2024 · 1 min · Rick Cui

adb 与安卓使用

查看包名 adb shell pm list package adb shell pm list package | findstr xxx 查看包的信息 adb shell pm dump com.xxx.xxx.xxx | findstr version adb shell dumpsys package com.xxx.xxx.xxx | findstr version 查看包的路径 adb shell pm path com.xxx.xxx.xxx 获取系统应用 adb shell pm list packages -s 获取第三方应用 adb shell pm list packages -3 启动指定 activity adb shell am start -n com....

December 23, 2023 · 2 min · Rick Cui