V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  wjx0912  ›  全部回复第 14 页 / 共 37 页
回复总数  734
1 ... 10  11  12  13  14  15  16  17  18  19 ... 37  
317 天前
回复了 lovke 创建的主题 程序员 程序员自由创业周记#5:加一上线
以前用过一个打卡软件,但是都坚持不下去。精神上支持楼主~
一楼+1
有点疑问,同类型的产品有独立的 app 比如滴答清单之类的,这个市场不是更大吗
觉得很 NB ,可能是我太菜了。。。
327 天前
回复了 raylei 创建的主题 程序员 现在桌面端的主流技术栈有怎样的?
一个 electron 多 100M 。装 50 个软件,也才 5t 。现在的硬盘也不会在乎这么点空间吧
大丈夫能屈能伸,何况道个歉又不吃亏
328 天前
回复了 sbldehanhan 创建的主题 Linux 有什么推介的终端管理软件?
windows 盗版 xshell ,mac 开源 tabby
328 天前
回复了 yaott2020 创建的主题 程序员 感觉 rust 门槛太高了
搬砖:包工头时不时抽你一鞭子
写 rust:编译器时不时抽你一鞭子
331 天前
回复了 webberone 创建的主题 程序员 win 台式和 mac mini 纠结
一手 16g 不如二手 32g
@ysc3839 谢谢
@zpd2009 谢谢。还是运行时没完全理解。但这种坑对新手实在是不友好
@Shatyuka windows 的 DllMain.DLL_PROCESS_ATTACH 执行的比较晚,所以不会有这个问题,对吧
@Shatyuka 正解。谢谢
@chingyat 嗯。这个是没问题的。但是 g_test 不是固定值(会从文本读取)。runtime 执行一堆 constructor 的顺序问题。
这个不是编译器 bug ,是未指定行为
```
搞定了,把:
std::string g_test1;
std::string g_test2;
改成:
__attribute__((init_priority(101))) std::string g_test1;
__attribute__((init_priority(101))) std::string g_test2;

参考:
https://stackoverflow.com/questions/43941159/global-static-variables-initialization-issue-with-attribute-constructor-i
```
猜测的原因:__attribute__((constructor))时,c++ runtime 还未初始化,std::string 的一些操作可能不稳定。

测试:
```
std::string g_test1;
std::string g_test2;

__attribute__((constructor))
static void init() {
g_test1 = "hello test1";
printf("init: %s\n", g_test1.c_str());
}

void hello_func1(void) {
g_test2 = "hello test2";
printf("Hello World: %s, %s\n", g_test1.c_str(), g_test2.c_str());

return;
}

void hello_func2(void) {
printf("Hello World: %s, %s\n", g_test1.c_str(), g_test2.c_str());

return;
}
```

在 hello_func2 里面,g_test1 无法打印,g_test2 正常。

不知道这个思路是否正确,求大神指点
不缺那一百块的话,13600KF -> 13600K
1 ... 10  11  12  13  14  15  16  17  18  19 ... 37  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2518 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 30ms · UTC 09:35 · PVG 17:35 · LAX 02:35 · JFK 05:35
Developed with CodeLauncher
♥ Do have faith in what you're doing.