C/C++ code beautifier

  • Thread starter Diego Andres Alvarez Marin
  • Start date
D

Diego Andres Alvarez Marin

Hi all!

Is there a linux tool that uses as input my ugly C/C++ code and
outputs a pretty and nice formated source code?

Regards,

Diego
 
R

Robert Gamble

Hi all!

Is there a linux tool that uses as input my ugly C/C++ code and
outputs a pretty and nice formated source code?

Regards,

Diego

Assuming you mean C and/or C++, yes, there are many. This is not on-topic
here though, you should ask in comp.unix.programmer or a linux group. You
could alternatively learn how to use a search engine and find all the
information you seek in a few seconds.

Rob Gamble
 
B

Ben Pfaff

Believe me that I spend 15 minutes before asking here and I did not
find anything... maybe I did not put the right words...

"c beautifier" hits lots of useful programs and links.
 
R

Richard Bos

Out of curiosity, when would C/C++ ever mean anything *other* than "C and/or C++"?

All too often, when someone uses the term "C/C++", it appears that they
mean "C and C++-with-objects-ignored, which is exactly the same thing,
isn't it?". Of course, it isn't the same thing at all, and such people
tend to run into problems trying to compile C code with a C++ compiler,
or vice versa.

Richard
 
V

Villy Kruse

"c beautifier" hits lots of useful programs and links.

Not to mention that normally linux comes with a butifier, as did most unix
systems for decades.

Villy
 
E

E. Robert Tisdale

Diego said:
Believe me that I spend 15 minutes before asking here
and I did not find anything...

You should have told us that in your original post.
Maybe I did not put the right words...

I used Google

http://www.google.com/

to search for

+"reformat C++"

and I found lots of stuff including:

http://www.vijayawadasite.com/home/cfaq/misc-environmental-issues.html

[30.2] Are there any pretty-printers that reformat C++ source code?

[snip]

In alphabetical order:

* Artistic Style is a reindenter and reformatter of C++, C and Java
source code. It is available from http://gene.md.huji.ac.il/~tald/astyle/
* C++2LaTeX is a LaTeX pretty printer. It is available from
http://mirriwinni.cse.rmit.edu.au/ftp/pub/languages/C++2LaTeX-4.0.tar.gz
* C-Clearly by V Communications, Inc. is a Windows program that
comes with standard formatting templates and also allows you to
customize your own. http://www.mixsoftware.com/product/ccl.htm
* GNU indent program may help. It's available at
http://www.arceneaux.com/indent.html. You can also find an "official"
GNU mirror site by looking at http://www.gnu.org/order/ftp.html or
perhaps the original GNU site, ftp://prep.ai.mit.edu/pub/gnu/ (e.g., if
the current version is 1.9.1 you could use
ftp://prep.ai.mit.edu/pub/gnu/indent-1.9.1.tar.gz).
* tgrind is a Unix based pretty printer. It usually comes with the
public distribution of TeX and LaTeX in the directory
"...tex82/contrib/van/tgrind". A more up-to-date version of tgrind by
Jerry Leichter can be found on: ftp://venus.ycc.yale.edu/pub in
[.TGRIND]. [Note: If anyone has an updated URL for tgrind, please let me
know ([email protected]).]

Finally, you might consider lgrind which is another C++ to LaTeX
translator (check for the closest mirror site of the ctan archive). The
following is a grind definition for C++ (but this one doesn't recognize
some new keywords such as bool or wchar_t, and it doesn't recognize a
file ending with .cpp as C++):

C++|c++|CC:\
:pb=\p\d?\:)cf:np=\)\d?;:bb={:be=}:\
:cb=/*:ce=*/:ab=//:ae=$:sb=":se=\e":lb=':\
:zb=@:ze=@:tb=%%:te=%%:mb=%\$:me=\$%:vb=%\|:ve=\|%:\
:le=\e':tl:id=_~\::\
:kw=asm auto break case cdecl char continue default do double else\
enum extern far float for fortran goto huge if int interrupt long\
near pascal register return short signed sizeof static struct\
switch typedef union unsigned while void\
#define #else #endif #if #ifdef #ifndef #include #undef # define\
endif ifdef ifndef include undef defined #pragma\
class const delete friend inline new operator overload private\
protected public template this virtual:
 
M

Mark McIntyre

Out of curiosity, when would C/C++ ever mean anything *other* than "C and/or C++"?

Quite frequently, people that use "C/C++" have the idea that the two
languages are so similar that they're interchangable, or that C is a subset
of C++, or that C++ is a superset of C. None of these is true, hence the
mere sight of C/C++ tends to send shivers up the regular's spines.
 
E

E. Robert Tisdale

Steve said:
Out of curiosity, when would C/C++ ever mean anything *other* than "C and/or C++"?

C++ was designed by the same people at Bell Labs.
C++ was designed to replace C and not compete with it.
C++ *subsumes* C.
Most popular implementations compile both C or C++.
 
K

Kevin Handy

Steve said:
Out of curiosity, when would C/C++ ever mean anything *other* than "C and/or C++"?

Roman numerals mixed with C operators? 100/100++ = 100/101 ~= 0.99
 
R

Richard Herring

E. Robert Tisdale said:
C++ was designed by the same people at Bell Labs.

bool same(std::string a, std::string b);

assert(same("Stroustrup", "Ritchie"));

Yeah, right.
 
C

Chris Hills

I always though that a C/C++ beautifier was ADA....

Runs off to find asbestos suit and a ticket off the planet :)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\
/\/\/ (e-mail address removed) www.phaedsys.org \/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
 
C

Charlie Gordon

Kevin Handy said:
C++"?

Roman numerals mixed with C operators? 100/100++ = 100/101 ~= 0.99

You will all agree that C/C++ is blatant undefined behaviour.
Because you cannot mix C and C++ in the same expression without an intervening
sequence point ;-)

Chqrlie.
 
J

Jason Taylor

E. Robert Tisdale said:
Diego said:
Believe me that I spend 15 minutes before asking here
and I did not find anything...

You should have told us that in your original post.
Maybe I did not put the right words...

I used Google

http://www.google.com/

to search for

+"reformat C++"

and I found lots of stuff including:

http://www.vijayawadasite.com/home/cfaq/misc-environmental-issues.html

[30.2] Are there any pretty-printers that reformat C++ source code?

[snip]

In alphabetical order:

* Artistic Style is a reindenter and reformatter of C++, C and Java
source code. It is available from http://gene.md.huji.ac.il/~tald/astyle/
* C++2LaTeX is a LaTeX pretty printer. It is available from
http://mirriwinni.cse.rmit.edu.au/ftp/pub/languages/C++2LaTeX-4.0.tar.gz
* C-Clearly by V Communications, Inc. is a Windows program that
comes with standard formatting templates and also allows you to
customize your own. http://www.mixsoftware.com/product/ccl.htm
* GNU indent program may help. It's available at
http://www.arceneaux.com/indent.html. You can also find an "official"
GNU mirror site by looking at http://www.gnu.org/order/ftp.html or
perhaps the original GNU site, ftp://prep.ai.mit.edu/pub/gnu/ (e.g., if
the current version is 1.9.1 you could use
ftp://prep.ai.mit.edu/pub/gnu/indent-1.9.1.tar.gz).
* tgrind is a Unix based pretty printer. It usually comes with the
public distribution of TeX and LaTeX in the directory
"...tex82/contrib/van/tgrind". A more up-to-date version of tgrind by
Jerry Leichter can be found on: ftp://venus.ycc.yale.edu/pub in
[.TGRIND]. [Note: If anyone has an updated URL for tgrind, please let me
know ([email protected]).]

Finally, you might consider lgrind which is another C++ to LaTeX
translator (check for the closest mirror site of the ctan archive). The
following is a grind definition for C++ (but this one doesn't recognize
some new keywords such as bool or wchar_t, and it doesn't recognize a
file ending with .cpp as C++):

C++|c++|CC:\
:pb=\p\d?\:)cf:np=\)\d?;:bb={:be=}:\
:cb=/*:ce=*/:ab=//:ae=$:sb=":se=\e":lb=':\
:zb=@:ze=@:tb=%%:te=%%:mb=%\$:me=\$%:vb=%\|:ve=\|%:\
:le=\e':tl:id=_~\::\
:kw=asm auto break case cdecl char continue default do double else\
enum extern far float for fortran goto huge if int interrupt long\
near pascal register return short signed sizeof static struct\
switch typedef union unsigned while void\
#define #else #endif #if #ifdef #ifndef #include #undef # define\
endif ifdef ifndef include undef defined #pragma\
class const delete friend inline new operator overload private\
protected public template this virtual:

Check out a Windows program called Crystal FLOW for C/C++ from
http://www.sgvsarc.com/

In addition to an excellent code beautifier, it creates flowcharts
from C/C++ code. Has a complete code browser too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top