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

Library version can now be extracted from header #33

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions auto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ $(I.DEST)/glew.h: $(EXT)/.dummy
perl -e "s/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;/" -pi $@
rm -f $@.bak
cat $(SRC)/glew_tail.h >> $@
perl -e "s/GLEW_VERSION_MAJOR_STRING/$(GLEW_MAJOR)/g" -pi $@
perl -e "s/GLEW_VERSION_MINOR_STRING/$(GLEW_MINOR)/g" -pi $@
perl -e "s/GLEW_VERSION_MICRO_STRING/$(GLEW_MICRO)/g" -pi $@

$(I.DEST)/wglew.h: $(EXT)/.dummy
@echo "--------------------------------------------------------------------"
Expand Down
17 changes: 8 additions & 9 deletions auto/src/glew_init_tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error)

const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)
{
static const GLubyte* _glewString[] =
switch (name)
{
(const GLubyte*)NULL,
(const GLubyte*)"GLEW_VERSION_STRING",
(const GLubyte*)"GLEW_VERSION_MAJOR_STRING",
(const GLubyte*)"GLEW_VERSION_MINOR_STRING",
(const GLubyte*)"GLEW_VERSION_MICRO_STRING"
};
const size_t max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
return _glewString[(size_t)name > max_string ? 0 : (size_t)name];
case GLEW_VERSION: return (const GLubyte*)"GLEW_VERSION_STRING";
case GLEW_VERSION_MAJOR: return (const GLubyte*)"GLEW_VERSION_MAJOR_STRING";
case GLEW_VERSION_MINOR: return (const GLubyte*)"GLEW_VERSION_MINOR_STRING";
case GLEW_VERSION_MICRO: return (const GLubyte*)"GLEW_VERSION_MICRO_STRING";
}

return NULL;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some compilers are prone to complaining about any switch statement without a default clause. If you don't mind shifting the NULL return into a default, I appreciate that.

}

/* ------------------------------------------------------------------------ */
Expand Down
8 changes: 4 additions & 4 deletions auto/src/glew_tail.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */

/* string codes */
#define GLEW_VERSION 1
#define GLEW_VERSION_MAJOR 2
#define GLEW_VERSION_MINOR 3
#define GLEW_VERSION_MICRO 4
#define GLEW_VERSION GLEW_VERSION_MAJOR_STRINGGLEW_VERSION_MINOR_STRING
#define GLEW_VERSION_MAJOR GLEW_VERSION_MAJOR_STRING
#define GLEW_VERSION_MINOR GLEW_VERSION_MINOR_STRING
#define GLEW_VERSION_MICRO GLEW_VERSION_MICRO_STRING

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in favour of these defines varying from one release to the next. It's too fragile in terms of matching the header to a precompiled library. I wonder if we could put the version information in a /* */ comment block in a manner that would be suitable for easy grepping, but would have no impact on the interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you are right. I just haven't thought about such weird case when someone could use library version different from header version. It's really not a way to go. It's the same as pkg-config returning not matching version. Whole point is to check version from header at configure time so you can make some decisions in build scripts. And many open-source libraries seem to be ok defining version info like header constants.

In the end of the day defining version info in comments can be an option. Honestly I don't like it but it's probably a matter of taste. Maybe we can introduce another 4 defines like a compromise. Anyway you are boss here it's up to you to decide. Just give us that ability to grep version from header.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take another look at this myself eventually, unless a fresh merge request appears. :-)

/* API */
#ifdef GLEW_MX
Expand Down