Discussion:
how to specify compile options for individual sources
(too old to reply)
m***@gmail.com
2008-06-19 18:39:59 UTC
Permalink
how can i specify compile flags for individual source files ? for example
a project has 2 source files. one needs to be linked with sdl and one
does not. it does work using the same cflags for all sources, but i
figure it would be better for larger projects to just use what is needed.

thanks

matt
Vaclav Slavik
2008-06-19 20:30:33 UTC
Permalink
Hi,
Post by m***@gmail.com
how can i specify compile flags for individual source files ?
You can't. Allowing this will take major changes.
Post by m***@gmail.com
for example a project has 2 source files. one needs to be linked with
sdl and one does not.
Source files cannot be linked. It's the executable that is linked as a
whole against SDL, so object files from _both_ of your source files are
"linked with sdl", in any build system. It's true that you don't need
compiler flags specific to SDL (that would be -I and -D, I assume),
but...
Post by m***@gmail.com
it does work using the same cflags for all sources,
...as you say, there's no real _need_ for that.
Post by m***@gmail.com
but i figure it would be better for larger projects to just use what is needed.
When linking, certainly. But using per-source cflags is not something
people normally do, when it's enough to set them per target.

Regards,
Vaclav
m***@gmail.com
2008-06-20 04:30:07 UTC
Permalink
Post by Vaclav Slavik
Hi,
Post by m***@gmail.com
how can i specify compile flags for individual source files ?
You can't. Allowing this will take major changes.
hmm.
Post by Vaclav Slavik
Post by m***@gmail.com
for example a project has 2 source files. one needs to be linked with
sdl and one does not.
Source files cannot be linked. It's the executable that is linked as a
whole against SDL, so object files from _both_ of your source files are
"linked with sdl", in any build system. It's true that you don't need
compiler flags specific to SDL (that would be -I and -D, I assume),
but...
right, typed that wrong, i meant the include that i get when i run
sdl-config --cflags
Post by Vaclav Slavik
Post by m***@gmail.com
it does work using the same cflags for all sources,
...as you say, there's no real _need_ for that.
Post by m***@gmail.com
but i figure it would be better for larger projects to just use what is needed.
When linking, certainly. But using per-source cflags is not something
people normally do, when it's enough to set them per target.
Regards,
Vaclav
thanks
matt

Loading...