Best way to control that compiler manage variable names longer then 8 signs.

C

Carramba

Hi!

I am wondering what is the best way to control that compiler manage
variable names longer then 8 signs.
Does it enought to set 2 variables with the same name and difference after
8 sign and se thats happends?
--
Thanx in advance!

;-)

______________________________________
I se the lightat the end, but every time I take a step it's get dim.
 
K

Keith Thompson

Carramba said:
I am wondering what is the best way to control that compiler manage
variable names longer then 8 signs.
Does it enought to set 2 variables with the same name and difference
after 8 sign and se thats happends?

You keep using the word "sign" when you mean "character". A sign is a
'+' or '-' character.

The C90 standard requires compilers to support internal identifiers of
at least 31 significant characters (case sensitive), and external
identifiers of at least 6 significant characters (possibly case
insensitive). C99 expands these limits to 63 and 31, respectively.

Most implementations support greater lengths than what the standard
requires, especially for internal identifiers.

It's vanishingly unlikely that you'll run into problems using
reasonable identifiers longer than 8 characters.
 
M

Mark McIntyre

The C90 standard requires compilers to support internal identifiers of
at least 31 significant characters (case sensitive), and external
identifiers of at least 6 significant characters (possibly case
insensitive). C99 expands these limits to 63 and 31, respectively.

Most implementations support greater lengths than what the standard
requires, especially for internal identifiers.

It's vanishingly unlikely that you'll run into problems using
reasonable identifiers longer than 8 characters.

I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

and so on.....
 
C

CBFalconer

Mark said:
.... snip ...

I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

and so on.....

Which is where my utility id2id would come in. One list of oldname
newname pairs could be used to revise every file in the system.
Ids are limited to 40 chars, but easily changed with a #define.
See:

<http://cbfalconer.home.att.net/download/id2id-20.zip>
 
R

Randy Howard

Which is where my utility id2id would come in. One list of oldname
newname pairs could be used to revise every file in the system.
Ids are limited to 40 chars, but easily changed with a #define.
See:

<http://cbfalconer.home.att.net/download/id2id-20.zip>

Seems like cscope could do this a long time ago, and you didn't have
to make a list ahead of time, you did it interactively.

I haven't looked at the details of your package, just the description
above.

If you wanted to batch it, wouldn't sed do the job?
 
C

CBFalconer

Randy said:
(e-mail address removed) says...

Seems like cscope could do this a long time ago, and you didn't have
to make a list ahead of time, you did it interactively.

I haven't looked at the details of your package, just the description
above.

If you wanted to batch it, wouldn't sed do the job?

id2id is a filter, it reads the file once, and makes all the
changes in a single pass. It is also reversible under mild
restrictions. So you can easily apply it to a whole set of files.
You also have a record of the changes, so you can go back and
change your mind easily.

I think I should change the identifier length to 64 to agree with
C99.
 
C

Carramba

You keep using the word "sign" when you mean "character". A sign is a
'+' or '-' character.

Iam sorry for my poor english, Iam trying my best.
The C90 standard requires compilers to support internal identifiers of
at least 31 significant characters (case sensitive), and external
identifiers of at least 6 significant characters (possibly case
insensitive). C99 expands these limits to 63 and 31, respectively.

Most implementations support greater lengths than what the standard
requires, especially for internal identifiers.

It's vanishingly unlikely that you'll run into problems using
reasonable identifiers longer than 8 characters.

thanx for answer, but Iam not affraid of runing into this proglem, it only
for educational purpose. So my questions stil unanswered?!
would it work to assgin first variable with 8 characters in lenght name
value, and then assign different value to 8+ long variable and call the
first one? should compiler (theoreticly) re-assign second value to first
variable if it coudn't hanle londer then 8 chars variable names?

ex
char Test_var;
char Test_variable;
Test_var='Y';
Test_varibla='N';
printf("In case of sussces you se Y & N , otherwise N & N\n%c & %c",
Test_var, Test_variable);

should something like that work?



--
Thanx in advance!

;-)

______________________________________
I se the lightat the end, but every time I take a step it's get dim.
 
J

Jack Klein

Iam sorry for my poor english, Iam trying my best.


thanx for answer, but Iam not affraid of runing into this proglem, it only
for educational purpose. So my questions stil unanswered?!
would it work to assgin first variable with 8 characters in lenght name
value, and then assign different value to 8+ long variable and call the
first one? should compiler (theoreticly) re-assign second value to first
variable if it coudn't hanle londer then 8 chars variable names?

ex
char Test_var;
char Test_variable;
Test_var='Y';
Test_varibla='N';
printf("In case of sussces you se Y & N , otherwise N & N\n%c & %c",
Test_var, Test_variable);

should something like that work?

EVERY C compiler is required by the C standard to document its limits
on names, both for internal use within a single file and for external
linkage.

Why don't you just read your compiler's documentation?
 
K

Keith Thompson

Carramba said:
thanx for answer, but Iam not affraid of runing into this proglem, it
only for educational purpose. So my questions stil unanswered?!
would it work to assgin first variable with 8 characters in lenght
name value, and then assign different value to 8+ long variable and
call the first one? should compiler (theoreticly) re-assign second
value to first variable if it coudn't hanle londer then 8 chars
variable names?

ex
char Test_var;
char Test_variable;
Test_var='Y';
Test_varibla='N';
printf("In case of sussces you se Y & N , otherwise N & N\n%c & %c",
Test_var, Test_variable);

should something like that work?

Test_var and Test_variable appear to be internal identifiers, so
they're absolutely guaranteed by both C90 and C99 to be distinct.
Unless you're using external identifiers, you can always count on 31
significant characters. Your implementation is required to document
what its actual limit is.

If you had something like this:

char this_is_a_very_long_identifier_1; /* 32 characters long */
char this_is_a_very_long_identifier_2;
this_is_a_very_long_identifier_1 = 'Y';
this_is_a_very_long_identifier_2 = 'N';

you could conceivably run into problems on an implementation that
actually limits identifers to 31 significant characters. The standard
says that "If two identifiers differ only in nonsignificant
characters, the behavior is undefined", so there's no way to tell what
the program is going to do.
 
C

Chris Croughton

I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

I shoot that sort of programmer on sight. Quite apart from portability
issues, it makes the program less readable and thus more error prone
(statements tend to straggle over lots of lines, or lines are
ridiculously long). When programmers also use "Hungarian" notation it's
far kinder to put them out of everyone's misery...

(I did my first programming in FORTRAN IV, where we had at most 6
characters for names, case insensitive. And then I went on to Unix
where a command name with more than three characters was considered too
much to type...)

Chris C
 
R

Richard Bos

Mark McIntyre said:
I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

Must've been a PasCal ProGrammer.

Richard
 
C

Chris Hills

Mark McIntyre said:
I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

and so on.....

Surely that converts to

ConvertTexToDVIFormatLittleEndia
and
ConvertTexToDVIFormatLittleEndia

after going through the compiler? :)

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

Keith Thompson

Chris Hills said:
Surely that converts to

ConvertTexToDVIFormatLittleEndia
and
ConvertTexToDVIFormatLittleEndia

after going through the compiler? :)

Not necessarily. C99 6.4.2.1p6 says:

Any identifiers that differ in a significant character are
different identifiers. If two identifiers differ only in
nonsignificant characters, the behavior is undefined.

so they don't necessarily just truncate. C90 has identical wording
(but different minimum limits).
 
M

Mark McIntyre

I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

Must've been a PasCal ProGrammer.[/QUOTE]

You're spot on, or pretty close anyway. An Academic.
 
C

Carramba

EVERY C compiler is required by the C standard to document its limits
on names, both for internal use within a single file and for external
linkage.

Why don't you just read your compiler's documentation?

it's wasn't my point to prov if compiler supports or don't long names, I
was asking if my way would by enought to test it.
I have no intension to writte meningles long names it's only for
educational purpose only.



--
Thanx in advance!

;-)

______________________________________
I se the lightat the end, but every time I take a step it's get dim.
 
K

kingzog

Mark said:
I ran into this about a decade ago, porting a Unix app to DOS. The idiot
that wrote the original used immensely annoying function names like

ConvertTexToDVIFormatLittleEndianQuadWord
ConvertTexToDVIFormatLittleEndian2ByteWord

This is yet another place where Hungarian Notation would come in handy
- if he'd used

leqwTe2DVCvt for ConvertTexToDVIFormatLittleEndianQuadWord

and lewTe2DVCvt for ConvertTexToDVIFormatLittleEndian2ByteWord

you wouldn't have had the problem, plus the code is self documenting.

Zog.
 
B

Ben Pfaff

kingzog said:
This is yet another place where Hungarian Notation would come in handy
- if he'd used

leqwTe2DVCvt for ConvertTexToDVIFormatLittleEndianQuadWord

and lewTe2DVCvt for ConvertTexToDVIFormatLittleEndian2ByteWord

you wouldn't have had the problem, plus the code is self documenting.

I hope that's meant to be sarcastic.
 
K

Keith Thompson

Carramba said:
it's wasn't my point to prov if compiler supports or don't long names,
I was asking if my way would by enought to test it.

And the answer is no. Using identifiers that differ only in
nonsignificant characters (e.g., whose first N characters are
identical, where N is what the implementation guarantees) invokes
undefined behavior. That means there is no way to test it. An
implementation that guarantees, say, 63 significant initial characters
for internal identifiers could treat all distinct 1000-character
identifiers as distinct *unless* one of them contains the letter 'Q'.

It's typical, I think, for compilers either to internally truncate
long identifiers, or not to impose any fixed limit at all, but that's
not guaranteed.
 
M

Mark McIntyre

This is yet another place where Hungarian Notation would come in handy
- if he'd used

leqwTe2DVCvt for ConvertTexToDVIFormatLittleEndianQuadWord

and lewTe2DVCvt for ConvertTexToDVIFormatLittleEndian2ByteWord

you wouldn't have had the problem, plus the code is self documenting.

The hit squad are on their way. I trust youv'e made a will....

=;-0
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top