TIP

1.

libcurl引入的时候必须要加载下面三个库

#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "wldap32.lib")

#pragma comment(lib, "crypt32.lib" )

32位程序需要引入前两个,64位程序需要引入这三个

然后要在property pages->c/c++->preprocessor->preprocessor definitions中添加CURL_STATICLIB

不然会报下面的错误
 error LNK2001: unresolved external symbol __imp_curl_easy_perform
 error LNK2001: unresolved external symbol __imp_curl_global_init
 error LNK2001: unresolved external symbol __imp_curl_global_cleanup
 error LNK2001: unresolved external symbol __imp_curl_easy_init
 error LNK2001: unresolved external symbol __imp_curl_easy_cleanup
 error LNK2001: unresolved external symbol __imp_curl_easy_setopt

2.

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

Configuration Properties->C/C++->Precompiled Headers->Precompiled Header->Not Using Precompiled Headers

3.

#pragma comment(lib, "shlwapi.lib")

后面必须跟lib名字,不可以加路径,如果要指定路径,那就在工程中配置对应lib的引用路径

4.

#include <Shlwapi.h>
#pragma comment(lib, "shlwapi.lib")

windows 判断目录是否存在,创建目录
if (!PathIsDirectory(str))
{
    ::CreateDirectory(str, NULL);
}

5.

用c++访问postgresql的时候,需要使用官方的libpq库,目前调查下来,这个libpq库是postgresql数据库编译出来时配对的。也就是不能像mysql一样,数据库是64位安装,可以自己编译32的connector访问。所以市面上的postgresql的connector都是在原生的libpq的基础上封装的。也就导致一个问题,就是安装什么样的postgresql,就会配戴什么样的connector。最大的影响就是数据库是32位还是64位,如果是64位,那么自己的程序也必须是64位,因为不可能在不同平台下相互访问lib库。并且从官方的release来看,postgresql从11.4开始就没有32位的发布了。所以,如果想用postgresql的话,最好尽早着手把自己的程序替换成64位

6.

查看postgresql的配置

SELECT * from pg_show_all_settings()

7.

mysql中有一个默认配置,就是空闲连接超时后自动kill掉,默认好像是8小时

postgresql中也有这个属性,默认是不主动kill,也就是关闭的,如果你需要可以打开,不过对于后端开发,这样更方便,避免了自己写keepalive的逻辑了

idle_in_transaction_session_timeout ( integer)

Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. This allows any locks held by that session to be released and the connection slot to be reused; it also allows tuples visible only to this transaction to be vacuumed. See Section 24.1 for more details about this.

The default value of 0 disables this feature.

8.

网络编程中如果出现

error C2011: 'sockaddr' : 'struct' type redefinition

类似的编译错误,原因就是因为在#include <WinSock2.h>前面包含了#include <Windows.h>

因为#include <Windows.h>中包含了#include <winsock.h>,而#include <winsock.h>中定义了与#include <WinSock2.h>一样名字的类型。现在都是#include <WinSock2.h>,#include <winsock.h>是比较老的功能了。名字一样但是里面的结构可能有区别,就导致报错。修改方法就是查看所有工程中引用#include <Windows.h>和#include <WinSock2.h>的地方,确保#include <WinSock2.h>在#include <Windows.h>前面。不仅仅是直接引用,也包括间接引用,比如你在引用#include <WinSock2.h>之前引用了其他头文件,其他头文件中引用了#include <Windows.h>,这样也是会报错

也可以在所有的引用最前面或是所有#include <Windows.h>前面定义#define _WINSOCKAPI_,因为在#include <winsock.h>通过#define _WINSOCKAPI_来判断是否引用这个头文件,所以可以提前定义让它不引用就可以了

9.

如果navicat连接远程的postgresql的时候报这个错误

no pg_hba.conf entry for host ssl off

那是因为postgresql默认是不允许外部连接的

所以需要修改安装目录下的pg_hba.conf文件

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

修改成

host    all             all             0.0.0.0/0            md5

这个文档上面有介绍,0.0.0.0/0表示允许所有ip

然后在开始菜单postgresql安装的目录下找到sql shell

运行select pg_reload_conf();重新加载配置,注意一定要加分号

10.

用navicat数据传输postgresql数据库的数据的时候,如果报下面的错误

column p.proisagg does not exist atabase d on d.datname = current_database() perhaps you meant to reference the column

表示你的工具太老了,我用的postgresql是11.4,navicat是12.0.18,需要下载最新的navicat 12.1.x

navicate破解

破解的github地址

https://github.com/Deltafox79/Navicat_Keygen

下载编译

安装最新的navicat

把编译出来的exe拷贝到navicat的目录,不拷贝也可以,就是到时候需要自己选择一下目录

运行破解软件

默认选项基本上不用改,对应好自己的版本,唯一有一点注意,我们下载的应该都是中文版的,languages选择中文

点击patch

提示navicat.exe-x64->cracked,表示成功

然后打开navicat

点击注册

点击破解软件serial keygen一行的generate生成注册码,然后把生成的注册码拷贝到navicat

点击激活,然后选择手动激活

然后把navicat的请求码拷贝到破解软件的required code中

点击activation code下面的generate

把activation code中的内容复制到navicat的激活码中

点击激活

可以参考

https://www.52pojie.cn/thread-867986-1-1.html

11.

使用string_view的时候需要c++17的支持。visual studio 2017已经支持。需要在

configuration properties->c/c++->language->c++ language standard选择引用

12.

decltype 返回一个数据的类型

decltype(1)就相当于int

decltype(1) a;->int a;//这是等价的

decltype(23.11) b;->double b;//这是等价的

std::declvaldecltype一起使用,作用就是调用一个结构体或是类的方法,但是不用实例化,直接用类名调用即可

不可以单独使用

struct Test
{
    int fun()
    {
        return 453;
    }
};
decltype(std::declval<Test>().fun()) a = 1;
//上面等价于
int a = 1;

std::declval<Test>().fun()就是调用Test中的fun函数,可以避免实例化一个Test

转载于:https://www.cnblogs.com/studywithallofyou/p/11187001.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值