-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
os./
on compiletime + crossCompilation behaves incorrectly.
#21534
Comments
A path created at compile time can be used at both compile time and run time. I think explicity specifying which OS the path used is better. type
PathOS = enum
poUnix
poWindows
Path[P: PathOS] = distinct string
when BuilOS == "windows":
BuildOSPath = Path[poWindows]
else:
BuildOSPath = Path[poUnix]
when TargetOS == "windows":
TargetOSPath = Path[poWindows]
else:
TargetOSPath = Path[poUnix]
static:
# Suppose cross compiling from linux for windows:
# echo unix path
echo getProjectPath().BuildOS / "foo.nim"
# echo windows path
echo getProjectPath().TargetOS / "foo.nim" Or add a proc explicity convert path: type
PathOS = enum
poUnix
poWindows
when BuilOS == "windows":
const BuildOSPath = poWindows
else:
const BuildOSPath = poUnix
when TargetOS == "windows":
const TargetOSPath = poWindows
else:
const TargetOSPath = poUnix
proc convertPath(to: PathOS): string
static:
# Suppose cross compiling from linux for windows:
# echo unix path
echo (getProjectPath() / "foo.nim").convertPath(BuilOSPath)
# echo windows path
echo (getProjectPath() / "foo.nim").convertPath(TargetOSPath) |
Related issue:#19558 |
Thank you @demotomohiro |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Then cross compile from linux for windows:
The output:
I expect the second line to be:
Nim Version
Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-03-14
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 26b7a74
active boot switches: -d:release
Current Output
Expected Output
Possible Solution
Fix os.
/
for compile time.Additional Information
No response
The text was updated successfully, but these errors were encountered: