|
Can you post code causing "very strange syntactical error messages " and maybe the struct
definitions including the relevent circular reference?
Mark
|
|
|
|
|
No, I can't. It's too large and depending on too many components. One of the errors is
H:\RawProc\TIFFProcessing.cpp(856) : error C2059: syntax error : '('
but this is on it's own useless. Some of the error messages are simply crazy (not fitting to the actual situation).
If I can't find a solution, I will create an abstract example and post that.
|
|
|
|
|
Something else is likely wrong - the location of that error (line 856) leads me to believe something else is going on here.
You may have to post all of the related code, or at least provide a way to get to it.
Edit - or at least lines 850-560...!
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Vancouver wrote: H:\RawProc\TIFFProcessing.cpp(856) : error C2059: syntax error : '('
It seems to be syntaxical one. Post some relevent code.
|
|
|
|
|
I created a simple example:
<br />
void main()<br />
{<br />
<br />
struct SampleStr2<br />
{<br />
char Anything;<br />
SampleStr2 *pNextStr;<br />
SampleStr1 *pSStr1;<br />
};<br />
<br />
struct SampleStr1<br />
{<br />
char Anychar;<br />
SampleStr2 *pSStr2;<br />
};<br />
<br />
return;<br />
};<br />
The error report is
<br />
error C2143: syntax error : missing ';' before '*'<br />
error C2501: 'SampleStr1' : missing storage-class or type specifiers<br />
error C2501: 'pSStr1' : missing storage-class or type specifiers<br />
|
|
|
|
|
void main()
{
struct SampleStr1;
struct SampleStr2
{
char Anything;
SampleStr2 *pNextStr;
SampleStr1 *pSStr1;
};
struct SampleStr1
{
char Anychar;
SampleStr2 *pSStr2;
};
return;
};
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I DID do it so, as I wrote it in the original post (my addition, that this did not correct the error was wrong).
My main point was and is, that this contradicts the MS VC++ 6.0 documentation.
|
|
|
|
|
So what's the point of your post then? If you need help with a problem, a solution has been provided. If you're just wanting to rant about MS's documentation, take a number. It's a known fact that you can't rely 100% upon MSDN documentation. While errors are rare, they do occur and thus you should be prepared to make corrections.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The docu of VC++6.0 is miserable, but that's not the same as factually erroneous. I haven't got used to the idea of fighting against factual errors in the documentation.
However, in fairness I have to say, that this is not an error in the docu. After re-reading the documentation, I realized it: it states only that the definition does not have to be prior the pointer, but it says nothing about the declaration.
|
|
|
|
|
To add to Joe, This proves, its always better to provide problem code snippet.
|
|
|
|
|
I am using Sleep(10) in my thread to post a windows message every 10ms.
In the function responding to the windows message, I find that it is being executed approximately every 16ms. Where does the 6ms delay come from? My computer is not the best 1.53GHz, but 6ms delay is still way too slow.
|
|
|
|
|
Posting a message puts it in a queue; the speed at which the messages are removed from the queue by the receiving thread need not be directly related to the rate at which they're posted. For example, factors such as the time taken to process the message and thread scheduling come into play.
Steve
|
|
|
|
|
Is there a way to accurately predict the actual time it takes to post a message? The function I'm using is depended on that time.
Is there another way I can force the function to execute at specified time intervals, and accurately? Is there something like time() that would return ms instead of seconds?
|
|
|
|
|
acerunner316 wrote: Is there a way to accurately predict the actual time it takes to post a message?
It doesn't take long to post a message as it's simply queued. The delay comes into play because of the contents of the queue, the speed at which the receiving thread calls GetMessage and processes the message and thread scheduling.
acerunner316 wrote: Is there another way I can force the function to execute at specified time intervals, and accurately?
Probably the most accurate way would be to use a dedicated high priority thread which calls the function directly then sleeps, in a loop. Naturally if the approach is feasible or not in your case depends on what your function does.
acerunner316 wrote: there something like time()
Check out GetTickCount .
Steve
|
|
|
|
|
Stephen Hewitt wrote: Probably the most accurate way would be to use a dedicated high priority thread which calls the function directly then sleeps, in a loop. Naturally if the approach is feasible or not in your case depends on what your function does.
The reason I am posting a message and not directly calling the function is because the function references members of the main class, and I remember reading somewhere that you can't do that in a thread. So how can I create a dedicated thread that calls the function directly.
Thanks.
|
|
|
|
|
That's not an easy question to answer without detailed knowledge about what you're trying to do and how you've gone about doing it.
Steve
|
|
|
|
|
Basically, my program is sampling data from an external USB device. The data is displayed in the window as well as logged to a file. I want to sample and log the data at a specified sampling rate. In this case, I chose every 10ms. The retrieval in done through API calls in the function that's responding to the windows message posted by the thread. My logic was that if I post the message every 10ms, the function will run every 10ms and therefore sampling rate will be 10ms. Clearly, this is not the case.
Hopefully that clears things up.
|
|
|
|
|
There are a number of approaches I'd consider:
The first is to abandon the idea of having “super accurate” callbacks. Instead just use a reasonably accurate mechanism, such as SetTimer or your current scheme, but record the time of each sample along with the sample data.
The second would be to use a high priority thread like I described earlier to do all the sampling and fill buffers which can be accessed by the UI thread – with appropriate synchronization.
On a side note be aware that posting messages from another thread is probably only marginally more accurate then using SetTimer .
Steve
|
|
|
|
|
well, it doesn't have to be super accurate, but 6ms delay out of the specified 10ms is huge. 1 or 2 ms might be acceptable.
Can you explain how I would use SetTimer to solve my problem, where would I call it?
Also can you explain how to use a high priority thread. Would I be able to access member variables/functions of the main class? Does it operate differently than a worker thread.
|
|
|
|
|
acerunner316 wrote: Can you explain how I would use SetTimer to solve my problem, where would I call it?
Calling SetTimer wouldn't solve your problem. I was just pointing out that using SetTimer instead of posting messages from a worker thread would be simpler and only marginally less accurate.
acerunner316 wrote: Also can you explain how to use a high priority thread. Would I be able to access member variables/functions of the main class? Does it operate differently than a worker thread.
When I said a "high priority" thread I simply meant a worker thread with a high priority. A thread's priority can be set using SetThreadPriority . Normally having a thread with a really high priority is a bad idea but since our thread spends most or its life asleep and when it is awake just takes a sample then goes back to sleep it’s ok. In this context the high priority is just to reduce the scheduling overhead so that our thread is chosen by the scheduler earlier than others when the sleep time has expired. As to accessing member variables of a class that’s a complex question which would require more detailed knowledge of your application.
Steve
|
|
|
|
|
acerunner316 wrote: Is there a way to accurately predict the actual time it takes to post a message?
no. and your process could get preempted at any time.
acerunner316 wrote: Is there another way I can force the function to execute at specified time intervals, and accurately?
not really. WM_TIMER isn't very accurate (or reliable).
acerunner316 wrote: Is there something like time() that would return ms instead of seconds?
QueryPerformanceCounter[^] might help with that.
|
|
|
|
|
Chris Losinger wrote: QueryPerformanceCounter[^] might help with that.
I think that's shooting a bit over the top. GetTickCount() is probably just about right for what he's trying to time.
--
Not based on the Novel by James Fenimore Cooper
|
|
|
|
|
he was talking about accuracy in the 10-20ms range. GetTickCount can't get near that.
|
|
|
|
|
So.. uh, the system timer resolution is too low? Lucky me that I don't have to do anything multimedia related, because I was under the impression that a timer which is given the attribute system would be the most accurate one. Thanks for the heads up - who knows? I might have to deal with issues like this some day...
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
it's updated every ~15ms to 50ms (depending on the version of Windows). so, it is measuring time in the ms range, but the difference between two consecutive calls will never be less than ~15ms.
QueryPerformanceCounter is much more accurate.
|
|
|
|