Click here to Skip to main content
15,885,767 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Query For CFileDialog? Pin
Alain Rist4-Nov-10 3:56
Alain Rist4-Nov-10 3:56 
QuestionError "string data,right truncated" generate when trying to Update by CRecordset? Pin
Le@rner3-Nov-10 18:57
Le@rner3-Nov-10 18:57 
AnswerRe: Error "string data,right truncated" generate when trying to Update by CRecordset? Pin
Stephen Hewitt3-Nov-10 19:33
Stephen Hewitt3-Nov-10 19:33 
GeneralRe: Error "string data,right truncated" generate when trying to Update by CRecordset? Pin
Le@rner3-Nov-10 19:34
Le@rner3-Nov-10 19:34 
AnswerRe: Error "string data,right truncated" generate when trying to Update by CRecordset? Pin
David Crow4-Nov-10 3:01
David Crow4-Nov-10 3:01 
QuestionInterlockedCompareExchange/cmpxchg-lock free queue Pin
Endaroza3-Nov-10 11:53
Endaroza3-Nov-10 11:53 
AnswerRe: InterlockedCompareExchange/cmpxchg-lock free queue Pin
Electron Shepherd3-Nov-10 13:52
Electron Shepherd3-Nov-10 13:52 
GeneralRe: InterlockedCompareExchange/cmpxchg-lock free queue [modified] Pin
Endaroza3-Nov-10 22:03
Endaroza3-Nov-10 22:03 
Hi!
Firstly thank you for the answer! I did'nt even knew that existed this keyword!!
The variables seems aligned to 4 bytes, that is 32 bit so it should be fine, as far as i know (that is honestly really a little...).
I tried using pointer variables as member variables, allocating them (with sizeof(variable)+4)and taking an address in the mallocated area that was aligned...and everything concluded with segmentation...
There is something that i don't quite understand into this...
Thank you!
Zak
---EDIT---
Now i tryed with a snippet took from MSDN about porting from Unix... and everything works as expected...same compiler options...same everything. Even the alignement of the variables used is ok....
#include <iostream>

using namespace std;



#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

class Pippo{
    LONG pappa;
public:
    LONG pippe;
    char test;
    LONG new_value;
    VOID doStuff(){
        printf("fuffa\r\n");
    };
};


DWORD WINAPI thread_function(PVOID arg)
{
     int count2;
     Pippo*pipp = (Pippo*)arg;
     printf("thread_function is running. %d\r\n",__alignof__(pipp->new_value));
     for (count2 = 0; count2 < 1000; count2++) {
          Sleep(10);
          printf("(T-%d)", pipp->new_value);
          InterlockedExchange(&pipp->new_value, 1);
     }

     Sleep(3000);
     return 0;
}

int main()
{
     HANDLE a_thread;
     DWORD a_threadId;
     DWORD thread_result;
     int count1;
    Pippo* pipp=new Pippo();
    pipp->new_value=1;
// Create a new thread.
     a_thread = CreateThread(NULL, 0, thread_function, (PVOID)pipp,0, &a_threadId);

     if (a_thread == NULL) {
          perror("Thread creation failed");
          exit(EXIT_FAILURE);
     }

     printf("entering loop\n");
     for (count1 = 0; count1 < 10000; count1++) {
          Sleep(1);
          printf("(P-%d)", pipp->new_value);
          InterlockedExchange(&pipp->new_value, 2);
     }

     printf("\nWaiting for thread to finish...\n");
     if (WaitForSingleObject(a_thread, INFINITE) != WAIT_OBJECT_0) {
          perror("Thread join failed");
          exit(EXIT_FAILURE);
     }

// Retrieve the code returned by the thread.
     GetExitCodeThread(a_thread, &thread_result);

     printf("\nThread joined\n");
     exit(EXIT_SUCCESS);
     return 0;
}


modified on Thursday, November 4, 2010 4:48 AM

GeneralRe: InterlockedCompareExchange/cmpxchg-lock free queue Pin
federico.strati3-Nov-10 23:47
federico.strati3-Nov-10 23:47 
AnswerSolved !###$@#$ Pin
Endaroza4-Nov-10 0:01
Endaroza4-Nov-10 0:01 
QuestionFind Count Of Bytes Written To An IStream [modified] Pin
Frederick J. Harris3-Nov-10 8:38
Frederick J. Harris3-Nov-10 8:38 
AnswerRe: Find Count Of Bytes Written To An IStream Pin
Electron Shepherd3-Nov-10 11:34
Electron Shepherd3-Nov-10 11:34 
GeneralRe: Find Count Of Bytes Written To An IStream Pin
Frederick J. Harris3-Nov-10 13:45
Frederick J. Harris3-Nov-10 13:45 
AnswerRe: Find Count Of Bytes Written To An IStream Pin
Frederick J. Harris4-Nov-10 4:23
Frederick J. Harris4-Nov-10 4:23 
QuestionHow can use Time Out for any function or thread? Pin
Le@rner3-Nov-10 2:30
Le@rner3-Nov-10 2:30 
AnswerRe: How can use Time Out for any function or thread (URL checker) Pin
Moak3-Nov-10 2:44
Moak3-Nov-10 2:44 
AnswerRe: How can use Time Out for any function or thread? Pin
David Crow3-Nov-10 3:17
David Crow3-Nov-10 3:17 
AnswerRe: How can use Time Out for any function or thread? Pin
yu-jian8-Nov-10 15:21
yu-jian8-Nov-10 15:21 
Questionhow to generate uid for header files Pin
lakshman rao3-Nov-10 2:22
lakshman rao3-Nov-10 2:22 
AnswerRe: how to generate uid for header files Pin
Cedric Moonen3-Nov-10 2:29
Cedric Moonen3-Nov-10 2:29 
AnswerRe: how to generate uid for header files PinPopular
CPallini3-Nov-10 2:50
mveCPallini3-Nov-10 2:50 
AnswerRe: how to generate uid for header files Pin
«_Superman_»3-Nov-10 6:17
professional«_Superman_»3-Nov-10 6:17 
GeneralRe: how to generate uid for header files Pin
lakshman rao8-Nov-10 2:56
lakshman rao8-Nov-10 2:56 
AnswerRe: how to generate uid for header files Pin
yu-jian4-Nov-10 15:20
yu-jian4-Nov-10 15:20 
QuestionNumber of instances running Pin
ganesh.dp2-Nov-10 23:53
ganesh.dp2-Nov-10 23:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.