当前位置:网站首页>在64位机器使用CMake编译32位程序
在64位机器使用CMake编译32位程序
2022-06-21 08:26:00 【油条生煎】
背景
在帮(去看电影的)wsf 同学做 DDL 作业的时候,遇到以下题目:
设有语句如下:
char *c1[] = {"Red","Green","Blue"};
char c2[][6] = {"Red","Green","Blue"};
32 位系统中下面哪一种说法是正确的?
A. sizeof(c1)加4 等于sizeof(c2)
B. sizeof(c1)加6 等于sizeof(c2)
C. sizeof(c1)大于sizeof(c2)
D. sizeof(c1)等于sizeof(c2)
本着负责的目的,决定手动实验。
实验环境
- Window 10
- CLion
- Version:2020.3.1
- Runtime version:11.0.9.1+11-b1145.63 amd64
- VM:OpenJDK 64-Bit Server VM by Jetbrains s.r.o
- Toolchains:
- MinGW-w64 6.0
- CMake:3.17.5
- Debugger:MinGW-w64 GDB(version:8.1)
方法
在 CMakeLists.txt 中进行以下设置:
set(CMAKE_C_FLAGS "-m32")
set(CMAKE_CXX_FLAGS "-m32")
备注:
- 如果要编译的程序是 C 程序,则使用第一条(CMAKE_C_FLAGS);
- 如果要编译的程序是 C++ 程序,则使用第二条(CMAKE_CXX_FLAGS)。
实验结果
选 B。
printf("%u\n", sizeof(c1)); // 12
printf("%u\n", sizeof(c2)); // 18
边栏推荐
- Unity .net 框架问题
- 2022-2028 global section valve industry research and trend analysis report
- C # implement callback
- WordPress obtains category name and link through category ID
- Global and Chinese market of Toro from 2022 to 2028: Research Report on technology, participants, trends, market size and share
- Give two strings S and T, and judge whether T is the word formed after rearrangement of S
- 4.4 Eval function replaces function
- MySql 过滤查询(以字母开头,以数字开头,非数字开头,非字母开头)
- [DB written interview 225] in Oracle, if the online redo log file is damaged, how to recover it?
- PS prompts "script error -50 general Photoshop error, how to solve it?
猜你喜欢

Listing of flaunting shares on Shenzhen Stock Exchange: market value of 4.2 billion, 9-month revenue decreased by 21% year-on-year

Zhongyi Antu submitted for registration: proposed to raise 600million yuan, with annual revenue of nearly 1.2 billion yuan

Use lua+redis+openresty to realize concurrent optimization of e-commerce Homepage

Vision_ Transformer code exercise

Ads Filter Design Wizard tool 2

日記(C語言總結)

This article takes you to interpret the advertising advantages of tiktok

Windows10 LAN shared folder process

Showctf web primer series
![[kotlin] first day](/img/51/18b394a6bf0ab74b71e5c59ad3341c.png)
[kotlin] first day
随机推荐
Improve code checking with annotations
Unity开发相关的博客收集
2022-2028 global postoperative pressure suit industry research and trend analysis report
Client construction and Optimization Practice
【kotlin】第一天
Is it safe to open a stock account at present? Can I open an account online directly?
1006 sign in and sign out (25 points)
WordPress media library supports uploading and previewing SVG icons
tidb4.0.0遇见的问题、报错总结(tiup部署)
Unity写多线程注意事项
4.8 inquirer-autocomplete-prompt
Two image enhancement methods: image point operation and image graying
写文章的markdown规则
Unity Detailed explanation of meta file function
[DB written interview 225] in Oracle, if the online redo log file is damaged, how to recover it?
Unity write multithreading considerations
Higher order functions in kotlin (first-class citizens)
2022-2028 global hydrogen engine industry research and trend analysis report
Unity . Net framework
Figure neural network and cognitive reasoning - Tang Jie - Tsinghua University