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

Custom preprocessor #5

Open
squeek502 opened this issue Sep 20, 2023 · 1 comment
Open

Custom preprocessor #5

squeek502 opened this issue Sep 20, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@squeek502
Copy link
Owner

squeek502 commented Sep 20, 2023

This would be a solution for the "Unavoidable divergences from the Windows RC compiler" which are all preprocessor related.

Most notably, it would be necessary for UTF-16 support.

This would likely be a large undertaking. A starting point might be to fork arocc.


EDIT: Experimenting with this here: https://github.com/squeek502/preresinator

@squeek502
Copy link
Owner Author

squeek502 commented Oct 21, 2023

Some notes on potential UTF-16 handling I had locally that are relevant:

  • Convert UTF-16 files to UTF-8
  • Surround converted files with
    #pragma code_page(65001)
    // file contents
    #pragma code_page(DEFAULT)
    

Need to ensure that the generated #pragma code_page lines aren't ignored due to them being part of an included file

  • Could do something like using #line 1 "<built-in>" and then documenting that such lines should not be ignored even if they are 'within' an included file
  • Can't really do something like putting the generated #pragma code_page's in the 'root' file since that wouldn't handle the case of an included file including a UTF-16 file
  • Could do something like (where root-file.rc is the root file and file.rc is any arbitrary included file)
    #line 1 "root-file.rc" // note that the 1 here is a totally fake line number since the following line is not part of the original file at all
    #pragma code_page(65001)
    #line 1 "file.rc"
    // file.rc contents
    

Also need to keep https://squeek502.github.io/resinator/windows/input-and-output-code-pages.html in mind. What rc.exe does is encode the output of the preprocessor as UTF-16, having already handled all the #pragma code_pages and done things like replaced invalid codepoints with <U+FFFD>, etc. This type of approach may end up being necessary to reach full compatibility without resinator specific behavior in the preprocessed output.

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

No branches or pull requests

1 participant