my solution - #14
Closed
qiforan wants to merge 1 commit into
Closed
my solution#14qiforan wants to merge 1 commit into
qiforan wants to merge 1 commit into
Conversation
Author
|
按照惯例,header 只声明不定义。此库却在 header 中定义了函数,所以要求多个 object 中只能有一个定义,不得不通过宏定义手动指定由哪个 object 进行定义。 |
archibate
approved these changes
Dec 15, 2021
archibate
left a comment
Collaborator
There was a problem hiding this comment.
感谢你提交作业和认真的解释!不过由于最后改动了根目录的内容,我打 79 分!
所以要求多个 object 中只能有一个定义,不得不通过宏定义手动指定由哪个 object 进行定义。
所以其实可以单独弄一个空的 .cpp 文件,指定这个 object 来实现 stb 的函数。
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>而这个文件可以放在 stbiw/impl.cpp 里,就可以供所有使用该函数的文件使用而不改动 main 的文件。
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.
stbiw为 header-only library ,没有源文件,不需要实际编译,因此设置 为 interface library.使用
target_include_directories可以让源文件通过尖括号方式 include.