473,698 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suffix allowed on expressions?

Hi!

Are suffixes allowed on expressions?

For example, is the following allowed:

#define SECONDS_PER_YEA R (60 * 60 * 365) UL

I found this in a C test at http://www.embedded.com/2000/0005/0005feat2.htm
,
however, I am not able to compile when using this macro (or just the
expression "a = (60 * 60 * 365) UL;").

Where in the standard does it say that it is allowed/not allowed?

It would also be interesting to hear if there are any faults in the
other questions and answers in the test.

BRs!
Jan 2 '08
41 3038
dspfun <ds****@hotmail .comwrites:
How about question 7, is it correct (referring to the test in the link
at the top of the thread)? :

int const * a const;
This is probably a typo for:
int const *const a;
although I would write such a declaration as, equivalently:
const int *const a;
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
Jan 3 '08 #21
In article <71************ *************** *******@5g2000h sg.googlegroups .com>,
dspfun <ds****@hotmail .comwrote:
>Could you give a pointer to where in the standard it says that an
integer (constant) can be typecasted to a pointer and the result is
implementati on dependent?
C89 3.3.4 Cast Operators

An abitrary integer may be converted to a pointer. The result
is implementation-defined. [45]
{footnote} [45] The mapping functions for converting a pointer to
an integer or an integer to a pointer are intended to be
consistent with the addressing structure of the execution
environment.

--
"Any sufficiently advanced bug is indistinguishab le from a feature."
-- Rich Kulawiec
Jan 3 '08 #22
On 4 Jan, 00:41, rober...@ibd.nr c-cnrc.gc.ca (Walter Roberson) wrote:
In article <7146c56f-be16-4c06-9a59-1a142d154...@5g 2000hsg.googleg roups.com>,

dspfun *<dsp...@hotmai l.comwrote:
Could you give a pointer to where in the standard it says that an
integer (constant) can be typecasted to a pointer and the result is
implementation dependent?

C89 3.3.4 Cast Operators

* An abitrary integer may be converted to a pointer. The result
* is implementation-defined. [45]

* {footnote} [45] The mapping functions for converting a pointer to
* an integer or an integer to a pointer are intended to be
* consistent with the addressing structure of the execution
* environment.

--
* *"Any sufficiently advanced bug is indistinguishab le from a feature."
* *-- Rich Kulawiec
Thank you, is the same valid for C99?
Jan 3 '08 #23
dspfun <ds****@hotmail .comwrites:
A more obscure approach is:
*(int * const)(0x67a9) = 0xaa55;
It's *extremely* obscure why one would give an rvalue a const
type.
--
int main(void){char p[]="ABCDEFGHIJKLM NOPQRSTUVWXYZab cdefghijklmnopq rstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwC IxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+= strchr(p,*q++)-p;if(i>=(int)si zeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Jan 4 '08 #24
dspfun wrote:
>
.... snip ...
>
Could you give a pointer to where in the standard it says that an
integer (constant) can be typecasted to a pointer and the result
is implementation dependent?
You can answer this sort of question more easily yourself, with a
text version of the C standard and grep. grep is available
everywhere. For the text version I suggest N869_txt.bz2, which is
a bzip2 compressed version of N869, and is available at:

<http://cbfalconer.home .att.net/download/>

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home .att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 4 '08 #25
Keith Thompson wrote:
CBFalconer <cb********@yah oo.comwrites:
>dspfun wrote:
>>>
... snip ...
>>>
Could you give a pointer to where in the standard it says that an
integer (constant) can be typecasted to a pointer and the result
is implementation dependent?

You can answer this sort of question more easily yourself, with a
text version of the C standard and grep. grep is available
everywhere. For the text version I suggest N869_txt.bz2, which is
a bzip2 compressed version of N869, and is available at:

<http://cbfalconer.home .att.net/download/>

n1256.pdf, available at
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf>,
is more current. It's PDF rather than plain text, which may or may
not be a problem.

I'm not convinced that a simple grep would be useful in this case.
For example, the word "typecast" appears nowhere in the standard.
What would you grep for?
For example, I just entered:

grep -n cast \stds\n869.txt | less

and got a set of roughly 60 lines. This took all of 2 seconds. It
shouldn't take much to hide that output and just save the line
numbers, which can then be used to illuminate all the areas of
interest.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home .att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 4 '08 #26
CBFalconer wrote:
Keith Thompson wrote:
>CBFalconer <cb********@yah oo.comwrites:

I'm not convinced that a simple grep would be useful in this case.
For example, the word "typecast" appears nowhere in the standard.
What would you grep for?

For example, I just entered:

grep -n cast \stds\n869.txt | less

and got a set of roughly 60 lines.
Yeah, but the OP is under the mistaken impression that "typecastin g" has
something to do with C, rather than with Hollywood. :-(

It would probably have been useful to have advised him that the word he
was searching for was 'convert'.
--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >
Jan 4 '08 #27
dspfun wrote:
A more obscure approach is:
*(int * const)(0x67a9) = 0xaa55;
The most obscure thing is what the `const` is for. A cast doesn't yield a
lvalue, so it's irrelevant whether it's const. Do you usually end the body
of main with `return (const int)0;`?

--
Army1987 (Replace "NOSPAM" with "email")
Jan 4 '08 #28
On 4 Jan, 01:46, Ben Pfaff <b...@cs.stanfo rd.eduwrote:
dspfun <dsp...@hotmail .comwrites:
A more obscure approach is:
*(int * const)(0x67a9) = 0xaa55;

It's *extremely* obscure why one would give an rvalue a const
type.
Can you explain what you mean?

Isn't 0xaa55 the rvalue, 0xaa55 is an integer constant, what is the
obscure thing about that?
Jan 4 '08 #29
dspfun <ds****@hotmail .comwrites:
On 4 Jan, 01:46, Ben Pfaff <b...@cs.stanfo rd.eduwrote:
>dspfun <dsp...@hotmail .comwrites:
A more obscure approach is:
*(int * const)(0x67a9) = 0xaa55;

It's *extremely* obscure why one would give an rvalue a const
type.

Can you explain what you mean?
"const" is attached to a type to make objects of that type
non-modifiable. But the result of a cast is never modifiable,
because it is not an lvalue. So the "const" keyword here is
useless.
--
char a[]="\n .CJacehknorstu" ;int putchar(int);in t main(void){unsi gned long b[]
={0x67dffdff,0x 9aa9aa6a,0xa77f fda9,0x7da6aa6a ,0xa67f6aaa,0xa a9aa9f6,0x11f6} ,*p
=b,i=24;for(;p+ =!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)bre ak;else default:continu e;if(0)case 1:putchar(a[i&15]);break;}}}
Jan 5 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1324
by: p.kosina | last post by:
Its just for my convienience: When saving new file in IDLE I HAVE to always manually add suffix .py, otherwise it is saved without ANY suffix. Can it be set somewhere? Thank you Pavel
12
2132
by: Iain Downie | last post by:
Dear list, we are getting a few folk trying to register for our birdwatching surveys with emails of the form: aname@phonecoop.coop, in other words with a 4 character ending (other examples are .info). Currently, I use a regexp to check on 'normal' emails with 3 chars..... function checkEmail() { var emailVar = document.shorter.email.value;
1
5005
by: Endif | last post by:
I am tring to execute the following SQL statements through the Iseries Navigator for DB2/V8.2, But i come up with an error saying recursion is not allowed in common table expression. This is a example i picked up from SQL cook book. I am not sure where i am wrong. Any help is appreciated WITH TEMP ( SUPV_ID,EMPID, FIRSTNAME) AS ( SELECT TV.SUPV_ID,TV.EMPID, TV.FIRSTNAME
3
1945
by: Green | last post by:
Hi, I have a question that when i surf the internet, i found out that using ..aspx suffix means using asp.net, using .jsp means using javaserver page, etc. But some don't have any suffix. For instance, http://daniel.gallery.whitelands.com/photos/newyorktrip , there is no such suffix. Can anyone tell me what kind of technology they are using? I appreciate!
9
12935
by: Hamish M | last post by:
Hi I am interested in opinions on this topic. I have heard that a suffix is not a good solution and type casts are much better for example. ----------------------------------------------------------------- #define MAX_UWORD (T_UWORD)65535
5
1564
by: Casey Hawthorne | last post by:
Since there was talk of if-then-else not being allowed in lambda expressions, the following is from "Dive into Python" The and-or conditional expression trick from page 41 of "Dive into Python" Wrap the arguments in lists and then take the first element. ''
0
1194
by: Lamy | last post by:
I am trying to set a culture in my skin file, I had used the following code in my skin file: <asp:Label ID="UserNameLabel" runat="server" Text='<%$ Resources: CreateNew, Label1UserName %>' AssociatedControlID="UserName" style="FONT-WEIGHT: bold;FONT-SIZE: 11px; COLOR: #000000"></asp:Label> from the globalResources and I get the following error: Expressions are not allowed in skin files.
3
6057
by: Ahmedhussain | last post by:
I am writing this query but didnt understand why isnt it working... Its giving me the error : INSERT INTO (, , , , , , , , , , , , , , , , , , , , ) VALUES ((select (.User_Id) as UserID from Job inner join Users ON (.User_Id = .User_Id) where .User_Id = '1') , @Cat_id, @Job_Description, @Job_Status, @JobTitle, @NumberOfPositions, @JobTenure, @ManagementLevel, @JobDuration, @EducationRequired, @Experience, @RequiredTravel, @Salary,...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.