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

Added __LINE__ const #180

Merged
merged 4 commits into from Feb 16, 2018
Merged

Added __LINE__ const #180

merged 4 commits into from Feb 16, 2018

Conversation

@CrazyHackGUT
Copy link
Contributor

@CrazyHackGUT CrazyHackGUT commented Feb 14, 2018

Added __line const. He always equals current code line.

Test code:

#include <sourcemod>

public void OnPluginStart()
{
    PrintToServer("Check magic Pawn consts...");

    PrintToServer("cellbits = %d", cellbits);
    PrintToServer("cellmax  = %d", cellmax);
    PrintToServer("cellmin  = %d", cellmin);

    PrintToServer("charbits = %d", charbits);
    PrintToServer("charmax  = %d", charmax);
    PrintToServer("charmin  = %d", charmin);

    PrintToServer("debug    = %d", debug);

    PrintToServer("__Pawn   = %x", __Pawn);
    PrintToServer("__line   = %d", __line);

    PrintToServer("ucharmax = %d", ucharmax);
}

example running test code
line number

@Drifter321
Copy link
Member

@Drifter321 Drifter321 commented Feb 14, 2018

This should probably be __LINE__ to be the same as the amxmodx one since it matches other languages. https://github.com/alliedmodders/amxmodx/blob/1a56577f7a3c8167f34cec0bbd443402f5636dcf/compiler/libpc300/sc1.c#L1463

compiler/sc2.cpp Outdated Show resolved Hide resolved
@CrazyHackGUT CrazyHackGUT changed the title Added __line const Added __LINE__ const Feb 14, 2018
@dvander
Copy link
Member

@dvander dvander commented Feb 16, 2018

this looks fine but it deserves additions to compiler/tests - ideally two, one testing that __LINE__ works as normal and another that it works in macro expansions. If you need assistance writing a test let me know - if you look in the folder it's straightforward, you just need an ok-blah.sp file and an ok-blah.out file containing the expected stdout.

@CrazyHackGUT
Copy link
Contributor Author

@CrazyHackGUT CrazyHackGUT commented Feb 16, 2018

Thanks. I added tests.

@dvander
Copy link
Member

@dvander dvander commented Feb 16, 2018

Thanks!

@dvander dvander merged commit cb79295 into alliedmodders:master Feb 16, 2018
2 checks passed
@CrazyHackGUT CrazyHackGUT deleted the line-const branch Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants