Skip to content

Add #pragma once #463

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Add #pragma once #463

wants to merge 3 commits into from

Conversation

AmyrAhmady
Copy link
Contributor

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
  • A New Feature
  • Some repository meta (documentation, etc)
  • Other

Additional Documentation:
Has compatibility for windows paths and directory separator

@AmyrAhmady AmyrAhmady requested a review from a team as a code owner October 7, 2019 09:58
@AmyrAhmady
Copy link
Contributor Author

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.

basefname=_cchar+1;
/* assign '_inc_includename' string to symname */
strcpy(symname,"_inc_");
strlcat(symname,basefname,sizeof symname);
Copy link
Member

Choose a reason for hiding this comment

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

How closely does this replicate all the behaviour here: https://github.com/pawn-lang/compiler/wiki/File-Inclusion

@AmyrAhmady
Copy link
Contributor Author

@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 AmyrAhmady requested a review from Y-Less October 10, 2019 10:50
@AmyrAhmady
Copy link
Contributor Author

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.

@stale
Copy link

stale bot commented Jan 8, 2020

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

@stale stale bot added the state: stale label Jan 8, 2020
@YashasSamaga
Copy link
Member

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.

@stale stale bot removed the state: stale label Oct 11, 2020
@stale
Copy link

stale bot commented Jan 10, 2021

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

@stale stale bot added the state: stale label Jan 10, 2021
@continue98
Copy link

How did this PR end?

@Y-Less @YashasSamaga

@stale stale bot removed the state: stale label May 30, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

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

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

Successfully merging this pull request may close these issues.

4 participants