Open
Conversation
创建.cpp文件 先宏定义STB_IMAGE_WRITE_IMPLEMENTATION, 再include头文件stb_image_write.h 这样做是因为stb_image_write将API和源码整合在了一个.h文件里,于是.h文件就同时包含了API声明和API定义。 这么做的原因可能是出于方便管理,一个.h文件总比一个.h文件加一个.cpp文件或.so文件更方便一些。 但是整合在一起后,我们又不希望每个include该头文件的其它文件每次都重新定义一遍API,所以就加了一个宏变量去限制它, 只有定义了该宏变量的文件,才会对API进行定义,其它文件只有API的声明部分。 通过此方法,最终实现了API声明和定义整合在一起,同时限制了重复定义的问题。
使用add_library是用来生成stbiw静态库的。 使用target_include_directories指定了stbiw库关联了当前目录(即/stbiw),且使用了public关键字,这将会传递给所有与stbiw库关联的文件,这些被关联的文件也会到/stbiw目录中去寻找可能需要的头文件。
Collaborator
|
可以哦
无法顺畅的大口呼吸,是活着的最好证明
…---Original---
From: ***@***.***>
Date: Thu, Jul 14, 2022 22:59 PM
To: ***@***.***>;
Cc: ***@***.***>;
Subject: [parallel101/hw01] Hw01 frsama (PR #100)
不太会用git,不知道这样可以吗?
You can view, comment on, or merge this pull request online at:
#100
Commit Summary
b3d6555 Create stb_image_write.cpp
0dd5fc7 Update CMakeLists.txt
File Changes
(2 files)
M stbiw/CMakeLists.txt (2)
A stbiw/stb_image_write.cpp (2)
Patch Links:
https://github.com/parallel101/hw01/pull/100.patch
https://github.com/parallel101/hw01/pull/100.diff
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
不太会用git,不知道这样可以吗?