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

What kind of white space is allowed in GLSL source? Is UTF-8 BOM allowed or not? #259

Open
tksuoran opened this issue Oct 1, 2024 · 1 comment

Comments

@tksuoran
Copy link

tksuoran commented Oct 1, 2024

Reading GLSL specification section 3.1. Character Set and Phases of Compilation, strictly speaking, no kind of white space is mentioned as allowed. This is probably a mistake?
Meanwhile,

The source character set used for the OpenGL Shading Language is Unicode in the UTF-8 encoding scheme.

says encoding is unicode. In unicode, BOM can be considered "zero width no-break space" (at least according to https://en.wikipedia.org/wiki/Non-breaking_space). This leaves open the question regarding how BOM should be treated. I know at least one OpenGL implementation where shader program linking fails when shader source contains BOM.

@dj2
Copy link
Contributor

dj2 commented Oct 14, 2024

The handling of space is done by the preprocessor, the output of the preprocessor is a token stream. So, the definition of what is a space character is in the normative reference of the c++ specification. Reading that spec (2.5.2 lex.pptoken) we get:

Preprocessing tokens can be separated by white space; this consists of comments (2.8), or white-space characters (space, horizontal tab, new-line, vertical tab, and form-feed), or both.

From that, I'd guess that a BOM is not a valid space character.

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

No branches or pull requests

2 participants