Thread: C Programming- Wrong forum, but where?: Generic IDE definitions?

  1. #1
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065

    C Programming- Wrong forum, but where?: Generic IDE definitions?

    C code is fairly generic. I code in K&R style, using tab stops (vim defines a tab as 8 space boundaries). Many editors, however, set the tab stops at some (please, no religious discussions about styles) other number. Thinking back to long ago, I remember something about putting magic above the code that would define all that stuff for some editors (GNU Emacs, etc).

    Is there a generic set of parameters that one can put at the top of a C code file that would define the width of the line, the number of spaces/tab, etc?

    A quick Google search revealed nothing, but I just cannot seem to come up with good phrases to search (I'm really bad at it).

    Any information would be greatly appreciated.

    Mods -- If you move this message to an appropriate forum (maybe GD?) that's okay with me.

    Thanks,
    Andy

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Hmm, #pragma( tabstop, 4 ) didn't seem to work. In all seriousness, though, I have no idea.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    No, there is no universal fix it for tabs.

    Certain editors have particular styles of comment lines to convey the info, but unless you happen to also use the same editor (or one which understands the comment), it just doesn't work.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Well, there should be. I hate it when, in a peer review, the folks say "I really think that your \ should be in a single line on the right." Maybe we should put this into the C 2019 standard .

    Thanks anyways,
    Andy

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You can set tabs to whatever you want in vim (:set tabstop=4) but then you want to make the shiftwidth the same if you use >> (:set shiftwidth=4).

    Since this literally is a tab character (\t) that is interpreted by an editor, the only place this can really be an issue is in "cut and paste" situations where the tab will get turned into spaces. So it would be meaningless, I think, to attempt what you are talking about. A \t is a single byte in the source code file; it does not make any sense to say "make it X spaces instead", that's the realm of the viewer.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. General forum question - if in wrong forum...
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 05:00 AM
  2. Replies: 0
    Last Post: 06-26-2004, 05:59 PM
  3. ASP.net forum that supports Access
    By Grayson_Peddie in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-18-2003, 01:44 AM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Assembly forum
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-18-2001, 08:03 PM