Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Use of undeclared identifier '__tg_promote1'' error in Objective-C++ project #210

Closed
uestchang opened this issue Jun 13, 2019 · 22 comments
Closed
Labels

Comments

@uestchang
Copy link

I have to use the project which is created by cocos creator , and the project include a module register so that i can't use < tgmath.h >.
The error of Xcode is" Use of undeclared identifier '__tg_promote1' "and"Expanded from macro 'floor' ".
I have no idea about how to work around and redeclaring the things ,please help me.
Your help is greatly appreciated .
:)

@ruslanskorb
Copy link
Owner

@uestchang What do you mean by module register?
Try to delete content of DerivedData folder - ~/Library/Developer/Xcode/DerivedData/*.
Which version of Xcode do you use?
Could you provide the build log?

@uestchang
Copy link
Author

uestchang commented Jun 14, 2019

Hello guys,I try tp clean DerivedData just like u said ,but it didn't work.
My Xcode version is 10.0 (10A255).
The build logs are as follows:

/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:362:28: error: use of undeclared identifier '__tg_promote1'
    } while (maskHeight != floor(maskHeight));
                           ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:56:31: note: expanded from macro 'floor'
#define floor(__x) __tg_floor(__tg_promote1((__x))(__x))
                              ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:403:67: error: use of undeclared identifier '__tg_promote1'
        movementRect.size.width = CGRectGetWidth(maskRect) * fabs(cos(rotationAngle)) + CGRectGetHeight(maskRect) * fabs(sin(rotationAngle));
                                                                  ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:33:27: note: expanded from macro 'cos'
#define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:403:67: error: use of undeclared identifier '__tg_promote1'
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:33:27: note: expanded from macro 'cos'
#define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:403:122: error: use of undeclared identifier '__tg_promote1'
        movementRect.size.width = CGRectGetWidth(maskRect) * fabs(cos(rotationAngle)) + CGRectGetHeight(maskRect) * fabs(sin(rotationAngle));
                                                                                                                         ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:36:27: note: expanded from macro 'sin'
#define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:403:122: error: use of undeclared identifier '__tg_promote1'
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:36:27: note: expanded from macro 'sin'
#define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:404:69: error: use of undeclared identifier '__tg_promote1'
        movementRect.size.height = CGRectGetHeight(maskRect) * fabs(cos(rotationAngle)) + CGRectGetWidth(maskRect) * fabs(sin(rotationAngle));
                                                                    ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:33:27: note: expanded from macro 'cos'
#define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:404:69: error: use of undeclared identifier '__tg_promote1'
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:33:27: note: expanded from macro 'cos'
#define cos(__x) __tg_cos(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:404:123: error: use of undeclared identifier '__tg_promote1'
        movementRect.size.height = CGRectGetHeight(maskRect) * fabs(cos(rotationAngle)) + CGRectGetWidth(maskRect) * fabs(sin(rotationAngle));
                                                                                                                          ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:36:27: note: expanded from macro 'sin'
#define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:404:123: error: use of undeclared identifier '__tg_promote1'
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:36:27: note: expanded from macro 'sin'
#define sin(__x) __tg_sin(__tg_promote1((__x))(__x))
                          ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:409:33: error: use of undeclared identifier '__tg_promote1'
        movementRect.origin.x = floor(CGRectGetMinX(movementRect));
                                ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:56:31: note: expanded from macro 'floor'
#define floor(__x) __tg_floor(__tg_promote1((__x))(__x))
                              ^
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:410:33: error: use of undeclared identifier '__tg_promote1'
        movementRect.origin.y = floor(CGRectGetMinY(movementRect));
                                ^
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm:35:
In file included from /Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/RSKImageCropper.h:37:
/Users/mabinhang/IosDemo/build/jsb-default/frameworks/runtime-src/proj.ios_mac/RSKImageCropper.framework/Headers/CGGeometry+RSKImageCropper.h:56:31: note: expanded from macro 'floor'
#define floor(__x) __tg_floor(__tg_promote1((__x))(__x))
                              ^
11 errors generated.

@uestchang
Copy link
Author

screenShot 2019-06-14 afternoon 2 50 11

@uestchang
Copy link
Author

image
It's so strange that when I choose the floor and right click and select JumpToDefinition , there are six items were shown;
However, in another project(an single page ios project) which work well,there are only one definition and jumpToDefiniton at <CoreGraphics/CoreGraphics.h> immediately.

@uestchang
Copy link
Author

I think that I found out what happen in my project ,in the project which was created by cocos creator engine , the <tgmath.h> is different from the common project.
But i still don't know how to fix this problem :((((

@uestchang
Copy link
Author

screenShot 2019-06-17 afternoon 3 53 38
screenShot2019-06-17 afternoon3 54 14

@uestchang
Copy link
Author

I think .mm extension cause Xcode complier use tgmath.h from C++ V1 instead of clang, but I have to use .mm extension in default.
In fact ,I have try to use .m to instead ,and then another error come up :(( , it seems that .mm extension is necessary for cocos creator project.

@uestchang
Copy link
Author

@ruslanskorb Hey bro ,is it possible to use math.h to instead tgmath.h ?
I try my best to fix the problem but all of them didn't work.

@ruslanskorb
Copy link
Owner

Hi @uestchang! It looks like a configuration problem. Could you try to disable Modules feature in the build settings? https://stackoverflow.com/questions/23333287/tgmath-h-doesnt-work-if-modules-are-enabled

@uestchang
Copy link
Author

@ruslanskorb I had tried to set Modules feature to NO ,it didn't work :( , by the way , I try to change compilers of my app target , also didn't work.

@uestchang
Copy link
Author

@ruslanskorb I had tried to set Modules feature to NO ,it didn't work :( , by the way , I try to change compilers of my app target , also didn't work.

In fact , in my wrong project ,the Modules feature is NO in default . In another project which of Modules feature is YES, the cropper work well .

@ruslanskorb
Copy link
Owner

ruslanskorb commented Jun 18, 2019

@uestchang Could you provide a sample project with your problem?

@ruslanskorb
Copy link
Owner

@uestchang Did you manage to solve the problem?

@uestchang
Copy link
Author

@ruslanskorb I am sorry about the late reply to you .I want to solve the problem ,it is hard and I spent a few days to try ,but it didn't work .
I will send a sample to you tomorrow as well as try to solve it in the meantime.

@uestchang
Copy link
Author

proj.ios_mac.zip
@ruslanskorb
This is a sample with the problem.

@ruslanskorb
Copy link
Owner

@uestchang Your sample project has several missing files and produces errors that are not related to this problem. Please, provide a correct sample.

@uestchang
Copy link
Author

@ruslanskorb sorry , i will check it and send a correct sample.

@uestchang
Copy link
Author

@ruslanskorb The whole project created by cocos creator is too big which include the engine content. I have compressed it but it's still over 100MB .Owing to this , I can't upload it here.

@uestchang
Copy link
Author

https://1drv.ms/u/s!AshYtZMJ4vKjh0I9fwYKiSM0zWMT?e=KIz8CV
@ruslanskorb
I upload the sampleProject.zip file to oneDrive .

The Xcode project path is "SampleProject/build/jsb-default/frameworks/runtime-src/proj.ios_mac"

@ruslanskorb
Copy link
Owner

@uestchang As a workaround, add the following code to RootViewController.mm after #import <RSKImageCropper/RSKImageCropper.h>:

#undef cos
#undef sin
#undef atan2
#undef pow
#undef sqrt
#undef fabs
#undef ceil
#undef floor
#undef round

@ruslanskorb ruslanskorb changed the title How to redeclaring the things in CGGeometry+RSKImageCropper.h? 'Use of undeclared identifier '__tg_promote1'' error in Objective-C++ project Jun 21, 2019
@ruslanskorb ruslanskorb removed their assignment Jun 21, 2019
@ruslanskorb
Copy link
Owner

@uestchang Fixed in 2.2.2.

@uestchang
Copy link
Author

OK ,thank you so much :)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants