C Code Editor Formatting Unix-Windows

K

Kayle

For preservation of indentation when moving the C source file from Windows
to Linux machine, what is the advice to format the code.
Should the code formatted using spaces instead of tabs?
When opened using nedit in Linux, the indentation was not preserved, or
should we limit the length of each line ?

Any advice on this ? Thanks
 
A

Andreas Kahari

For preservation of indentation when moving the C source file from Windows
to Linux machine, what is the advice to format the code.
Should the code formatted using spaces instead of tabs?
When opened using nedit in Linux, the indentation was not preserved, or
should we limit the length of each line ?

Any advice on this ? Thanks

[off-topic]
The formatting of the code has no impact on the functionality
of the program. The indentation should be such that the code
is readable, but whether you use tabs or spaces (or, like me, a
mix of them) is not important unless you're working in a group
with weird formatting requierments. Hmmm... regarding the line
length. The line length is not really important either. Keep
it short to increase readability.

Consult system specific groups for questions regarding porting
non-standard functionality.


[on-topic]
A standard related question for the group: I'm reading the
rationale for section 7.19.2, which says that C99 increased the
minimum maximum line length from 254 to 4095, but the standard
itself says in 7.19.2 ("Streams") nothing about 4095... Is there
a mismatch here between the standard and the rationale?

I'm not sure this has anything to do with the length of lines in
a program source. Does it?
 
N

Nathan

For preservation of indentation when moving the C source file from Windows
to Linux machine, what is the advice to format the code.
Should the code formatted using spaces instead of tabs?
When opened using nedit in Linux, the indentation was not preserved, or
should we limit the length of each line ?

Any advice on this ? Thanks

I've configured my editor to replace tabs by spaces, in that case you don't
have such problems with formats when using your files on other platforms or
in other editors. The length of each line could make the layout of your code
look a bit strange if your editor wraps lines.

Regards,
Nathan
 
C

Christian Bau

Andreas Kahari said:
[on-topic]
A standard related question for the group: I'm reading the
rationale for section 7.19.2, which says that C99 increased the
minimum maximum line length from 254 to 4095, but the standard
itself says in 7.19.2 ("Streams") nothing about 4095... Is there
a mismatch here between the standard and the rationale?

I'm not sure this has anything to do with the length of lines in
a program source. Does it?

Why would capabilities of streams have anything to do with properties of
the language? Capabilities of streams would be interesting to know if
you write a compiler for _any_ language in C and use streams to read
source lines. But a compiler for the C language can be written in any
language you wish to use. The limit for a C source line is there to make
life easier for people writing C compilers _in any language they
choose_.
 
A

Andreas Kahari

Andreas Kahari said:
[on-topic]
A standard related question for the group: I'm reading the
rationale for section 7.19.2, which says that C99 increased the
minimum maximum line length from 254 to 4095, but the standard
itself says in 7.19.2 ("Streams") nothing about 4095... Is there
a mismatch here between the standard and the rationale?

I'm not sure this has anything to do with the length of lines in
a program source. Does it?

Why would capabilities of streams have anything to do with properties of
the language? Capabilities of streams would be interesting to know if
you write a compiler for _any_ language in C and use streams to read
source lines. But a compiler for the C language can be written in any
language you wish to use. The limit for a C source line is there to make
life easier for people writing C compilers _in any language they
choose_.

That's what I thought, good.

As it happens, I found the place where the standard says that
the maximum length of a logical source line is 4095 (section
5.2.4.1), which happens to correspond to the maximum length of
a line in a stream, according to the rationale anyway. The
values conincide, which is probably so that one *could* parse a
C source file with a program written in C.

Is the rationale out of sync with the standard regarding the
maximum line length in a stream?
 
K

Kayle

Nathan said:
I've configured my editor to replace tabs by spaces, in that case you don't
have such problems with formats when using your files on other platforms or
in other editors. The length of each line could make the layout of your code
look a bit strange if your editor wraps lines.

Regards,
Nathan

Thanks Nathan.
 
E

E. Robert Tisdale

Kayle said:
For preservation of indentation when moving the C source file
from Windows to Linux machine, what is the advice to format the code.
Should the code formatted using spaces instead of tabs?
When opened using nedit in Linux, the indentation was not preserved.
Or should we limit the length of each line?

Read the man pages for expand and unexpand.
They will help you convert the tabs to the correct number of spaces.

Also, read your man page for nedit.

-tabs n
Set tab stops every n characters.
 
K

Kayle

E. Robert Tisdale said:
Read the man pages for expand and unexpand.
They will help you convert the tabs to the correct number of spaces.

Also, read your man page for nedit.

-tabs n
Set tab stops every n characters.

The question is not how to set the tab or expand/unexpand.
It is how to preserve the format when transferring the C code between
Windows and Unix machine.

Thank you for giving comments.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top