compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Add #pragma once

Open AmyrAhmady opened this issue 6 years ago • 8 comments

What this PR does / why we need it:

  • Adds #pragma once, like old compiler, now you can use #pragma once to include the file only once

Which issue(s) this PR fixes:

Fixes #419

What kind of pull this is:

  • [ ] A Bug Fix
  • [x] A New Feature
  • [ ] Some repository meta (documentation, etc)
  • [ ] Other

Additional Documentation: Has compatibility for windows paths and directory separator

AmyrAhmady avatar Oct 07 '19 09:10 AmyrAhmady

Seems like AppVeyor build failed for some reason, it works well on my machine (Win10, VS 2017) Also Travis CI build passed, would be glad if someone find me what's wrong.

AmyrAhmady avatar Oct 07 '19 10:10 AmyrAhmady

@Y-Less it only adds _inc_includefilename.extention to table, now that I read wiki, seems like I'm doing it wrong. For example, you can have two main.inc in different directories and that way the second one just gets ignored. What's your idea about this one? It can be helpful.

AmyrAhmady avatar Oct 07 '19 11:10 AmyrAhmady

Now what it does is:

with these lines of code:

#include <a_samp>
#include <ColAndreas>
#include <ColAndreas>
#include <float>
#include <ColAndreas>
#include <float>
#include "../../ColAndreas"

that I added #pragma once to colandreas.inc and float.inc, they only get included once. and these are my debug messages:

Symbol: _inc_float.inc | Added to table
Symbol: _inc_ColAndreas.inc | Added to table
Symbol: _inc_ColAndreas.inc | Already in table
Symbol: _inc_float.inc | Already in table
Symbol: _inc_ColAndreas.inc | Already in table
Symbol: _inc_float.inc | Already in table
Symbol: _inc_../../ColAndreas.inc | Added to table

There's also one more thing to mention, #pragma once does not work when compiler is running with -Z arg; Tell me if I'm doing it wrong.

AmyrAhmady avatar Oct 10 '19 10:10 AmyrAhmady

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 08 '20 11:01 stale[bot]

I think it's better if the include guard symbol does not contain the separators. We need some abstract OS independent symbol name. I think it would be even better to avoid using symbols altogether and use global list of includes.

YashasSamaga avatar Oct 11 '20 11:10 YashasSamaga

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 10 '21 14:01 stale[bot]

How did this PR end?

@Y-Less @YashasSamaga

continue98 avatar May 30 '21 17:05 continue98

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 09 '22 02:01 stale[bot]