当前位置:网站首页>在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
边栏推荐
- Dumping backup database
- Nodejs post request JSON type and form type
- Unity 5 自帶的Mono也可以支持C# 6
- showCTF Web入门题系列
- doc常用语法,更新中……
- 2022-2028 global boom cylinder industry research and trend analysis report
- php exec、 system 、shell_ Exec cannot be executed. There is no result. The result is nulld. Solution
- Construct URL and Base64 download in the form of binary stream for file download
- TiDB3.0- 4.0 内存控制/修改日志保存天数/最大索引长度
- [DB written interview 225] in Oracle, if the online redo log file is damaged, how to recover it?
猜你喜欢
随机推荐
[kotlin] premier jour
[DB written interview 274] in Oracle, what is deferred segment creation?
Mono of unity 5 can also support C # 6
给定一个m*n的二维列表,查找一个数是否存在
How to build a deep learning framework?
Introduction to testing - Software Test Model
The market value of Jinshan office fell below 100 billion yuan: the shareholder Qiwen n-dimensional cash out exceeded 1.2 billion yuan
2022-2028 global internal gear motor industry research and trend analysis report
Figure neural network and cognitive reasoning - Tang Jie - Tsinghua University
[DB written interview 366] stored procedures are codes stored in the database and have many advantages. Among the following statements, which are not the advantages of stored procedures are ()
日记(C语言总结)
4.5 dataset usage document
Vision_ Transformer code exercise
Unity 5 自帶的Mono也可以支持C# 6
Kotlin---- detailed explanation of data types
Joking Domain Driven Design (VI) -- Boundary context -- Design
Difference between function declaration and function expression
(greedy) B. avoid local maximums
Global and Chinese market for packed gas chromatographic columns 2022-2028: Research Report on technology, participants, trends, market size and share
Given a two-dimensional list of m*n, find out whether a number exists
![[kotlin] first day](/img/51/18b394a6bf0ab74b71e5c59ad3341c.png)





