What's wrong with this picture in MFC VC++ 6.0?

I have the following union

typedef union {
	struct stJunk {
		unsigned char var1 : 1;
		unsigned char var2 : 1;
		unsigned char fill : 6;
	}stJunk;
	unsigned char uJunk;
} Junk;

Junk junk; // declare junk union variable

I can do
	junk.stJunk.var1 = 0;
	junk.stJunk.var2 = 1;

but not
	junk.uJunk = 0x2; // <--- Compile C2143 and C2059 errors.

Why?

This works in GNU!


-Zilla


0
2/11/2004 4:11:48 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
359 Views

Similar Articles

[PageSpeed] 57

> I have the following union
>
> typedef union {
> struct stJunk {
> unsigned char var1 : 1;
> unsigned char var2 : 1;
> unsigned char fill : 6;
> }stJunk;
> unsigned char uJunk;
> } Junk;
>
> Junk junk; // declare junk union variable
>
> I can do
> junk.stJunk.var1 = 0;
> junk.stJunk.var2 = 1;
>
> but not
> junk.uJunk = 0x2; // <--- Compile C2143 and C2059 errors.
>
> Why?
>
> This works in GNU!
>
>


It also works for me with VS6, haven't tried VS7.x

-- 
Bjarne Nielsen


0
2/11/2004 5:18:35 PM

Bjarne Nielsen wrote:
>>I have the following union
>>
>>typedef union {
>>struct stJunk {
>>unsigned char var1 : 1;
>>unsigned char var2 : 1;
>>unsigned char fill : 6;
>>}stJunk;
>>unsigned char uJunk;
>>} Junk;
>>
>>Junk junk; // declare junk union variable
>>
>>I can do
>>junk.stJunk.var1 = 0;
>>junk.stJunk.var2 = 1;
>>
>>but not
>>junk.uJunk = 0x2; // <--- Compile C2143 and C2059 errors.
>>
>>Why?
>>
>>This works in GNU!
>>
>>
> 
> 
> 
> It also works for me with VS6, haven't tried VS7.x

It works in 7.

Best, Dan.


0
lakeweb1 (82)
2/11/2004 5:26:23 PM
Is it possible that the error occurs in a line somewhere before junk.uJunk =
0x2;

Normand

"Zilla" <zilla62XSPAM@bellsouth.net> a �crit dans le message de news:
9vsWb.10206$QE3.531@fe01.usenetserver.com...
> I have the following union
>
> typedef union {
> struct stJunk {
> unsigned char var1 : 1;
> unsigned char var2 : 1;
> unsigned char fill : 6;
> }stJunk;
> unsigned char uJunk;
> } Junk;
>
> Junk junk; // declare junk union variable
>
> I can do
> junk.stJunk.var1 = 0;
> junk.stJunk.var2 = 1;
>
> but not
> junk.uJunk = 0x2; // <--- Compile C2143 and C2059 errors.
>
> Why?
>
> This works in GNU!
>
>
> -Zilla
>
>


0
NoEmail9920 (149)
2/12/2004 5:31:06 AM
Reply:

Similar Artilces:

Clipart Gallery
Hi I used to work with Publisher 2000 which had a foretune of clipart installed. Whenever I would click to add a picture and do a search for something e.g. "man" - I would get dozens of images appearing. I upgraded to Publisher 2003, and when I do the exact same thing I am lucky if it shows 3 images on each search. What am I doing wrong, and why cannot I access all those images that used to be available on my previous version? Thanks. Jo Office 2003 shipped with very little clipart, there are 130,000 images on the Office site. If you are online when you search these pictur...

Problem with MFC menu
I've been using a couple of computers to build an application (98&XP) and just added another computer laptop in the mix. For some reason on the laptop the MFC menus display a white rectangle in the menu area. When you click on a menu item, the whole menu turns to white background (text is still black). I then created a new MFC app and the menus behave the same way. However, other programs such as Visual Studio menus do not exhibit the behaviour. Does anyone have an idea what I can look for to fix this problem? My guess would be that its the video driver of your laptop. See if updati...

Pictures on CRM
On May of this year I posted a question about to handle several images or pictures on Microsoft CRM unfourtunaly my computer hard drive was broken and I losto everything also the page of the code for a script I remember that the solution was using the image folder of the share point 2.0 using a script to add the control to the micrsoft account screen Hope that anybody can help me I can't find my question to thanks Hi Gustavo Could you explain the requirement in detail once again. I suppose you would be using custom pages and IFRAMES to show pictures on the form. -- Regards - May...

wrong email address sends
How do I make Outlook send the correct email address and not a business account that I do not want going out with my messages I'm not sure if I understand your question correctly -- are you asking how to force Outlook to send messages through one account rather than another? If so, I need some more information from you before I can answer: What version of Outlook are you using, and if 98 or 2000, what mail support mode? If you're not sure, look at the second line of Help | About Microsoft Outlook -- it should say "Internet Mail Only" or "Corporate/Workgroup". ...

What wrong with sumproduct function?
I would like to sum all numbers, which match following conditions, =SUMPRODUCT(($B$1816:$B$2400=$A2402),(C$1816:C$2400<0),(C$1816:C$2400)) press ctrl + shift + enter but it returns zero, and I have checked it, zero should not be the result. Does anyone have any suggestions what wrong with sumproduct function? Thanks in advance for any suggestions Eric 1. Sumproduct is not an array function. Use Enter, not Ctrl-Shift-Enter. 2. You must convert false/trues to numbers. One way: =SUMPRODUCT(($B$1816:$B$2400=$A2402)*(C$1816:C$2400<0)*(C$1816:C$2400)) Regards, Fred "E...

Pictures unintentionally stretches
Hi! If I use the default style in Excel, add some pictures to the sheet and print preview, it looks fine. If I change the default style, say the font to Arial Narrow 8 instead of Arial 10, the pictures on the sheet gets stretched (unproportionally). This has to be a bug? / Oskar ...

Emails shown with wrong date in overview-screen?
hello NG, i have the following problem: i have made a constellation of folders in witch i sort my incoming and outgoing mail to. now i have found the following phaenomenon: in one of these folders i see a bunch of mail (sent by myself) witch all seem to be sent on the same date, 15. december 2004. but in reality this is the wrong date, they have been sent over a long period reaching back even until 2001. if i doubleklick on the mail and view it the correct date is shown. only in the "overview-screen" where all the mails are listed, the date is shown wrong. what can i do about ...

.NET usercontrol in MFC propertypage
Hi, What would it take to put a .NET usercontrol (System.Windows.Forms.UserControl) on a CPropertyPage ?? I can expose the .NET usercontrol to MFC as a ActiveX component (implementing nessecary interfaces and registering the .NET control in the registry) and build a wrapper for this ActiveX in my MFC app. Then it should be fairly easy to put the control on the page, right?? Is there some special initialization I must in my MFC app before using the wrapped .NET ActiveX ?? I think not as it goes through COM, right ?? Kr. Soren ...

Cutomizing Print Dialog + MFC
Hi, I have customized the standard Print dialog for my application.(I did it the way it has been given in the MSDN http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com: 80/support/kb/articles/q132/9/09.asp&NoWebContent=1). But I am having a peculiar problem. The icon that appears in the Copies area is clipped when collate button is checked. Does anyone can let me know how to overcome this. -- Regards, Amar Kumar. ...

[ANN]VTD-XML 2.0
The VTD-XML project team is proud to announce the release of version 2.0 of VTD-XML, the next generation XML parser/indexer. The new features introduced in this version are: * VTD+XML version 1.0: the world's first true native XML index that is simple, general-purpose and back-compatible with XML. * NodeRecorder Class that saves VTDNav's cursor location for later sequential access. * Overwrite capability * Lexically comparisons between VTD and strings To download the software, please go to http://sourceforge.net/project/showfiles.php?group_id=110612 To read the latest benchmark repo...

export pictures to my computer?
How do I export pictures from my email to my computer? Open and Save As? "W. Wells" <otf70@nc.rr.com> wrote in message news:4588409d$0$18134$4c368faf@roadrunner.com... > How do I export pictures from my email to my computer? > > W. Wells <otf70@nc.rr.com> wrote: > How do I export pictures from my email to my computer? If they're attachments, right-click and Save As. If they're embedded, see this: http://www.howto-outlook.com/howto/saveembeddedpictures.htm -- Brian Tillman ...

Wrong Date/Wrong amount
In the Money 2004 check register it reports the last download date as well as the balance in the top left corner. The only problem is that it is totally wrong. It reports some bogus amount with a "downloaded" date of 10/9/2003. It is quite stubborn as nothing seems to affect it. Does anyone have any idea of how to correct this? Dirty Harry Harry Calahan wrote: > *In the Money 2004 check register it reports the last download dat > as > well as the balance in the top left corner. The only problem i > that > it is totally wrong. It reports some bogus amount wi...

Using VC .NET 2003 MFC Class wizard #2
No one ever answered this person's question, and I've yet to find anything remotley close on the net--I know this is not an uncommon situation--There is something seriously broke and/or underdocumented in the class wizard implementation in VC7. My situation is similar. I have a resource-only DLL (for localization) that has a bunch of dialog templates in it. I wish to use the class wizard to generate classes for those templates (they are actually property pages) and have those classes be generated in another project, which is a dialog-based application with no resources. Is there an...

Help please
I screwed something up and need help big-time. Somehow the default position of the cursor when I start a new document - or Outlook mail message - is in the right center part of the page. In fact, if I even open a document, it's formatted with everything scrunched over to the right. I can backspace and get the cursor to the right and it's not a big problem on documents with simple formatting, but for some complex documents, simply backspacing makes the formatting even worse. HELP PLEASW. -- rpbilleaud For a start, see http://word.mvps.org/FAQs/AppErrors/BlankDo...

Set up simple inventory counting sheet GP 8.0
I want to count several of the raw material components at one small warehouse we have. Is there a way I can use the stock counting programs in GP 8.0 without assigning all the items selected in my site/component list to be counted in some specific shedule. I set up my first count sheet and the program forced me to put in a scheduled number of days for the list of item/site list before I could print out the count sheet. THe stock count cycle assignment window required a number of days entry to be entered. You can setup a count sheet by simply adding the items manually to the count. ...

Exchange 2003 & Veritas 9.0 ( oh yes,that again...)
we have an Exchange 2003 in a win2003 domain... we also have a server with Veritas Backup Exec 9.0 Rev. 4432 installed... I guess whoever sees this topic will know that there must be an account with access to all mailboxes and especially must not have the Deny permission of the Receive As & Send As permission checked. Well I followed all the instructions given by people of MS and Veritas and I accomplished nothing...(big chances of my fault) I created the new security group which is a member of Exchange Domain Servers and added one account which has a mailbox into that group... Then I went...

What's going wrong in Outlook 2003?
Hello, When I installed the new Office 2003, I had no problems with Outlook 2003. I received and send mails whenever I want. A few days later, I get a message from outlook that Outlook could not make a connection with the server of my provider to get my mail on my computerb (I didn't change any settings!). I checked all my settings and there are good (I checked the mailserversettings, ports, etc) but the result is still the same: Outlook cannot make a connection with the mailserver. After that, I called my provider to ask them what to do. They told me that I must remove all the ...

What Am I Doing Wrong?
The application I'm modifying is a fairly standard example of an MFC MDI app. There are several CToolBars created in MainFrm.cpp. The code to respond to the buttons on these toolbars is in the View.cpp file. One of these toolbars I modified to contain a slider. I derived a new class, CViewToolBar, from CToolBar and modified it to have a slider. I'm having problems with two major things: the correct way to include the new class information so that MainFrm knows about it to create the new toolbar, and how to get the view to respond to WM_HSCROLL messages from the slider. I had ...

wrong number in cell
In XP PRO & Excel 2002 I have a cell formated as General and unlocked. I try to enter a number { 08607100 } I hit enter and it changes to { 8607100 } no matter what I try it. This is another example of a problem in a cell I enter { 03E2 } hit enter and it changes to { 3.00E+02 }. Is there some bug in certain cells or with excel 2002 or is there some setting I am missing? Help -- Thanks MK pipco wrote: > In XP PRO & Excel 2002 I have a cell formated as General and unlocked. I > try to enter a number { 08607100 } I hit enter and it changes to { 8607100 &g...

Recurring split bills download wrong!
Money 2004: I have recurring bills with estimated amounts and splits. When I change the amount/splits and submit for payment, the check is being handled just fine through MSN Bill Pay. When I download the consummated transaction from Wells Fargo, however, Money is pulling in my ESTIMATED splits instead of my ACTUAL splits for that payment. Hence the splits never match the actual payment amount, and I get a warning. What a pain. This problem started when I switched from Wells Fargo bill pay to MSN. As I see it, though, it's Money's job to keep track of the splits internally, t...

Random crash messages in CRM 4.0
Hello, We've been struggling with this issue for a long time and I have just been tasked with resolving it. We get an error message in CRM almost randomly (it cannot be duplicated by any specific means I know of) and it asks to send it to Microsoft, and never returns anything further. I looked at the error messages we are getting, and this one is typical: ***************** <CrmScriptErrorReport> <ReportVersion>1.0</ReportVersion> <ScriptErrorDetails> <Message>Object required</Message> <Line>197</Line> ...

Contact data is in wrong field
Hi all - I need some help with a complicated problem. I am working on a PST file that was recovered from some old data. Unfortunately, the recovery put contact data in the wrong places. Here are a few examples: 1. Contact street address and city shows up in the "Follup up flag" field 2. Contact "Email display as" contains the display as information with the email address, but the email address field is empty 3. Many duplicates of data with slightly different information (Same contact might have 3 copies, one with a missing telephone number, another with a missing emai...

Time wrong in meeting requests
We have Exchange 2000 and the following issue. When some (not all) users send a meeting request they are, in effect, one hour behind other Exchange users. For example User A sends a meeting request for 1pm - 2pm to User B. For User B the meeting shows up as 2pm - 3pm. Inversely, if User B sends a meeting request to User A for 4pm - 5pm it shows up as 3pm - 4pm for User A This starting happening on Friday (before daylight savings time for the first user to report it). The time is correct on the systems in question. The time is correct on the Exchange Server I don't have a clue so any cons...

Split cells #6
Hi, I have the following data "Sep 8 2005 12:00:00:000AM" and need i splitting down so that only the sep 8 2005 is in the cell. Formattin the cell will not work (unless I am doing something wrong). Please help - thank you in advanc -- moglione ----------------------------------------------------------------------- moglione1's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2641 View this thread: http://www.excelforum.com/showthread.php?threadid=46991 Is your entry a 'text' entry or a numeric entry with special formatting to display MDY HH:...

MFC still supported?
Hi, we are just planning the migration of a large C++ application with an old-UI-library to a new class library. We consider MFC and .NET to be our options. But: is it still a clever idea to port to MFC? It would be cheaper and faster today since we don't have to worry about Managed Code but is MFC still supported? Will there be new versions for Longhorn, for Windows2007, ...? Thanks in advance, Kay >But: is it still a clever idea to port to MFC? It would be cheaper and >faster today since we don't have to worry about Managed Code but is >MFC still supported? Kay, M...