Skip to content
New issue

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

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

Already on GitHub? # to your account

Not having a main() function causes a crash on Windows #111

Closed
ThomasWilshaw opened this issue Jan 4, 2023 · 1 comment · Fixed by #112
Closed

Not having a main() function causes a crash on Windows #111

ThomasWilshaw opened this issue Jan 4, 2023 · 1 comment · Fixed by #112

Comments

@ThomasWilshaw
Copy link
Contributor

According to the CTL spec. all CTL files must contain either a main() function or a function with the same name as the source file. However in Windows only the main() function approach works as the way this is implemented in ctlrender is whatever is after the last / in the file path of the ctl file is looked for as a function name. This breaks on Windows as Windows uses \ rather than /. This is even mentioned in a comment in transform.cc.

My proposed solution is to use #ifdef WIN32 to look for backslashes rather than forward slashes in transform.cc:346. I'll also have a look at adding a test for this but I'm not sure how far I'll get with that as I've never used this test suite before.

ThomasWilshaw added a commit to ThomasWilshaw/CTL that referenced this issue Jan 4, 2023
* fix module main function finding on Windows

* add improved error handling when correct function name cannot be
  found
@michaeldsmith
Copy link
Collaborator

Can you try adding a test for this so it could be run with Ctest ?

I think you just need to add something like this to \CTL\unittest\ctlrender\CMakeLists.txt

add_test(NAME "ctlrender-ctl-function-name-is-filename" COMMAND ctlrender -force -ctl functionname_is_filename.ctl bars_photoshop.exr out.exr)

and then add the CTL file functionname_is_filename.ctl to the folder \CTL\unittest\ctlrender\

michaeldsmith added a commit that referenced this issue Jan 6, 2023
* fix ctlrender's main function finding function on Windows, fixes #111 

* check for both forward and backslash in win32

* add test using functionname_is_filename.ctl

* add improved error handling when correct function name cannot be found

* add a test that checks ctlrender fails when a ctl module does not
  contain a function name that is either main or the same as the
  module name

* add incorrect_function_name.ctl

Co-authored-by: michaeldsmith <37905569+michaeldsmith@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants