cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[SUGGESTION] Give me a cppfront compiler flag which gives me a standalone cpp1 file I can send to a friend/competiitve programming judge

Open ed-aka-yaboi opened this issue 7 months ago • 10 comments

Will your feature suggestion eliminate X% of security vulnerabilities of a given kind in current C++ code? If yes, please be specific about the classes of bugs that would go away, with an example or two (especially a link to a real CVE or two).

No

Will your feature suggestion automate or eliminate X% of current C++ guidance literature? If yes, please be specific about what current good guidance this helps make the default, and/or what guidelines we would no longer need to teach/learn or that would be simplified and how, with an example or two (especially a link to a real "Effective C++" or "C++ Core Guidelines" guideline or two). For ideas, you can refer to my CppCon 2020 talk starting at 10:31 where I summarize a categorized breakdown based on over 600 C++ guidance literature rules I cataloged and analyzed.

Not standalone, but it will enable different types of experiments with cpp2, which will hopefully improve adoption

Describe alternatives you've considered. There's nearly always more than one way to improve something. What other options did you consider? Why is the one you're suggesting better than those?

Manually copy paste the included/imported files which the generated file references.

Wins

  • able to try out cpp2 on leetcode/codeforces/timus. This is how I learned cpp initially and I'd like to repeat that experiment with cpp2
  • able to send a single cpp1 file + the corresponding cpp2 file to a colleague so that they can look at the cpp2 file, be impressed by it, and verify that the corresponding cpp1 file compiles to expected output without making any changes to their dev env

ed-aka-yaboi avatar Jun 05 '25 09:06 ed-aka-yaboi

Are you looking to embed the content of the cpp2util.h and cpp2regex.h into the generated cpp1 file?

gregmarr avatar Jun 05 '25 14:06 gregmarr

If that's required to be able to compile the generated cpp file without installing anything other than gcc then yes.

ed-aka-yaboi avatar Jun 05 '25 15:06 ed-aka-yaboi

That seems to be a very specialized use case. Personally, I think sending those two headers along with your source file would be simple enough. Most of the time it would only be cpp2util.h, you only need cpp2regex.h if you use the compile-time regex metafunction.

gregmarr avatar Jun 05 '25 16:06 gregmarr

Except it doesn't work on online judges (leetcode/codeforces/we) that currently support cpp.

On Thu, 5 Jun 2025, 17:32 Greg Marr, @.***> wrote:

gregmarr left a comment (hsutter/cppfront#1401) https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945180759

That seems to be a very specialized use case. Personally, I think sending those two headers along with your source file would be simple enough.

— Reply to this email directly, view it on GitHub https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945180759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBXSAVJMWSJVBCNGL246GD3CBWJLAVCNFSM6AAAAAB6U4UMR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBVGE4DANZVHE . You are receiving this because you authored the thread.Message ID: @.***>

ed-aka-yaboi avatar Jun 05 '25 17:06 ed-aka-yaboi

The cpp2util.h is 3100+ lines. Would you be able to submit a C++ file that large to the online judge?

gregmarr avatar Jun 05 '25 17:06 gregmarr

Timus allows files of up to 5M. Codeforces files of up to 64K.

Leetcode doesn't advertise their file limits in an easily googlable way

On Thu, 5 Jun 2025, 18:31 Greg Marr, @.***> wrote:

gregmarr left a comment (hsutter/cppfront#1401) https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945398935

The cpp2util.h is 3100+ lines. Would you be able to submit a C++ file that large to the online judge?

— Reply to this email directly, view it on GitHub https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945398935, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBXSATPHBL47WWSW7MPNU33CB5IJAVCNFSM6AAAAAB6U4UMR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBVGM4TQOJTGU . You are receiving this because you authored the thread.Message ID: @.***>

ed-aka-yaboi avatar Jun 05 '25 17:06 ed-aka-yaboi

Sorry - looks like code forces has since bumped the limit to 256K.

On Thu, 5 Jun 2025, 18:35 Edward G, @.***> wrote:

Timus allows files of up to 5M. Codeforces files of up to 64K.

Leetcode doesn't advertise their file limits in an easily googlable way

On Thu, 5 Jun 2025, 18:31 Greg Marr, @.***> wrote:

gregmarr left a comment (hsutter/cppfront#1401) https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945398935

The cpp2util.h is 3100+ lines. Would you be able to submit a C++ file that large to the online judge?

— Reply to this email directly, view it on GitHub https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945398935, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBXSATPHBL47WWSW7MPNU33CB5IJAVCNFSM6AAAAAB6U4UMR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBVGM4TQOJTGU . You are receiving this because you authored the thread.Message ID: @.***>

ed-aka-yaboi avatar Jun 05 '25 17:06 ed-aka-yaboi

Herb doesn't have much time to work on this project right now (especially with a standards committee meeting in just over a week), so a PR to embed rather than include the headers would probably be the only way to get this done in a reasonable timeframe.

gregmarr avatar Jun 05 '25 18:06 gregmarr

Happy to close it as won't do given how small the file size limit is for codeforces (and how small it's likely to be on leetcode).

Thanks for your time :)

On Thu, 5 Jun 2025, 19:28 Greg Marr, @.***> wrote:

gregmarr left a comment (hsutter/cppfront#1401) https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945612532

Herb doesn't have much time to work on this project right now (especially with a standards committee meeting in just over a week), so a PR to embed rather than include the headers would probably be the only way to get this done in a reasonable timeframe.

— Reply to this email directly, view it on GitHub https://github.com/hsutter/cppfront/issues/1401#issuecomment-2945612532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBXSARHWRHMAE5PX6275N33CCD6TAVCNFSM6AAAAAB6U4UMR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBVGYYTENJTGI . You are receiving this because you authored the thread.Message ID: @.***>

ed-aka-yaboi avatar Jun 05 '25 20:06 ed-aka-yaboi

I do not think that this is a proper extension for cppfront. For two reasons:

  • It is a very special usecase.
  • There are tools available that can do this.

E.g.:

  • https://github.com/JamesBoer/Heady
  • https://github.com/rindeal/Amalgamate

I think, I have used Heady. But it has been quite a while.

Hope this helps.

MaxSagebaum avatar Jun 06 '25 06:06 MaxSagebaum