|
Hi,
Member 12335695 wrote: hWaits is an array of 32 handles
That is a alot of synchronization objects for a single thread. Please perform an audit/review on your code and check to see if your application is using greater than MAXIMUM_WAIT_OBJECTS which is probably defined as 64 on your operating system. Exceeding this number will cause failures at run-time that the compiler does not catch.
You might want to ask your engineers to design a better architecture that does not require single threads to wait on such a large number of handles.
Also please paste the entire contents of the "Debug Assertion Failed!" error message so we can further assist.
Best Wishes,
-David Delaune
modified 10-Nov-16 10:38am.
|
|
|
|
|
Please find the contents of the "Debug Assertion Failed!" error message as:
Debug Assertion Failed!
Program: C:\Windows\system32\mfc120ud.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\barstat.cpp
Line: 99
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp(1628) : AppMsg - Warning: no message line prompt for ID 0xE001.
Even though I restricted the synchronization objects to 2 only, then also I am getting the above same error.
Please let me know if you need more information on this?
|
|
|
|
|
And also, the creating events are:
hInterruptEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
hTDEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
hWaits[0]=hInterruptEvent;
hWaits[1]=hTDEvent;
Thanks,
Lakshmi Chowdam.
|
|
|
|
|
Member 12335695 wrote: Program: C:\Windows\system32\mfc120ud.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\barstat.cpp
Line: 99
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp(1628) : AppMsg - Warning: no message line prompt for ID 0xE001.
This means that your status bar is missing an ATL/MFC resource string for the ATL_IDS_IDLEMESSAGE.
Add this to your .RC resource file:
STRINGTABLE
BEGIN
ATL_IDS_IDLEMESSAGE "Ready"
END
You may be missing other resource strings.
Best Wishes,
-David Delaune
|
|
|
|
|
Look at the call stack to see what the assertion was checking, that should give you clues as to where the actual problem may be. Are you using the same exact MFC version (other than 32v64bit) on both compilations?
|
|
|
|
|
I developed an exe,which would exports some pure C APIs for plugin dlls.
the code for the main exe is something like bellow:
class CA{};
class CB{};
class CC{};
class CCore
{
private:
CA* m_pCA;
CB* m_pCB;
CC* m_pCC;
};
void main()
{
CCore* pCore = new CCore;
while(true)
{
pCore->DoSomething();
}
delete pCore;
}
the code for a plugin is something like this
class CTestPlugin : public IPlugin
{
public:
virtual void Init()
{
}
virtual void UnInit()
{
}
};
I do not want to expose the pCore pointer or any other pointers from main exe to any plugin. so I need pure c style apis.
any ideas?thank you.
modified 10-Nov-16 2:40am.
|
|
|
|
|
|
Just hold make an internal array of PCore pointers and pass them out an Index number ... call it a handle ... I guess a HPCORE.
So they hold onto an index number and when they call a function the pass in the index number and you grab back the PCore pointer out of your array.
That is what all the HANDLES are in Windows, they have a number it tells them nothing about what happens internally it just a index to a internal pointer that never comes out. So you code becomes more like Windows API and they can have multiple HPCore handles.
void main()
{
HPCORE hPCore = CreateNewPCore();
while(true){
PCoreDoSomething(hPCore);
}
DestroyPCore(hPCore);
}
EDIT: Actually I am being slow do what windows does exactly pass back a pointer to the position in the internal array rather than the index as the handle. First saves having to use the number to traverse the array to get the pointer (so much much faster). Second you can test the handle being valid if you need because it must lie between PCoreArray[0] ... PCoreArray[Last] of your internal PCore pointer array. It's index position in the array which you only need to know when you dispose to empty the slot is straight forward
Handle Index = (Handle - &PCoreArray[0])/sizeof(Pointer).
So a handle is a PCore** .. that is a pointer to a pointer to a PCore but I would just typedef it as size_t and internally typecast it because you can check it via the above. So ...
typedef size_t HPCORE;
In vino veritas
modified 10-Nov-16 21:33pm.
|
|
|
|
|
thank you all very much!!!
|
|
|
|
|
Write a program that determines a student's grade. It reads three test scores(between 0 and 100) and calls a function that calculates and returns a student's grade based on the following rules:
A. If the average score is 90% or more, the grade is A.
B. If the average score is 70% or more and less than 90%, it checks the third score. If the third score is more than 90%, the grade is A; otherwise, the grade is B.
and it continues...
The program's main is to contain only call statements. At least three subfunctions are required: one to read scores, one to determine the grade, and one to print the results.
This is what I have so far but it will not run for me. I am not allowed to use global declarations.
#include <stdio.h>
int main (void)
{
int score1, score2, score3;
char grade;
int temp = 0;
printf("Enter the test score (0-100): ");
scanf ("%d", &score1);
printf("Enter the test score (0-100): ");
scanf ("%d", &score2);
printf("Enter the test score (0-100): ");
scanf ("%d", &score3);
printf("The grade is: %c\n", score1, score2, score3);
return 0;
}
int temp = 0;
{
temp = (score1+score2+score3)/3;
if (score >= 90)
grade = 'A';
else
if (score >= 80)
grade = 'B';
else
if (score >= 70)
grade = 'C';
else
if (score >= 60)
grade = 'D';
else
grade = 'F';
char grade;
if (score >= 90)
grade = 'A';
else
if (score >= 80)
grade = 'B';
else
if (score >= 70)
grade = 'C';
else
if (score >= 60)
grade = 'D';
else
grade = 'F';
return grade;
}
help please
|
|
|
|
|
You need to hit the books or web lessons on C again. Your 3 statement inputs look good ... sorry that is it
Your printf statement is garbage hit the web or books and look up the words "formatted output of printf" and look at what %c means. However you have done absolutely nothing with the inputs to even think about calling that.
What we are saying is you need to call a function between the last input and trying to print anything ... so
scanf ("%d", &score3);
printf("The grade is: %c\n", score1, score2, score3);
You even have the text that boldly says "// Function declarations" only you don't have anything there you just drop straight into main. Let me guess that was a hint in the template they gave you and you don't even get what it means?
ScoreToGrade which was obviously was intended as your function is hanging out way down the bottom. You need to either forward declare it where you boldly declare you are going to have "// Function declatations" or move it up to there. So it's a cut and paste job or look up how to forward declare a prototype.
Final problem
int temp = 0;
It says it is local it is in fact a global variable ... you need to work out why.
In vino veritas
|
|
|
|
|
Hi Friends,
I have been asked in interviews like "How explicit , volatile and mutable keywords works INTERNALLY in C++ ?" Please let me know.
Rgeards,
Amrit
|
|
|
|
|
|
Explicit and volatile you need to know, if you are seen using mutable in C++ we put you up against the wall and shoot
There are a couple of places you need volatile the two main ones are in multitasking code and interfacing to physical hardware. What volatile tells the compiler the result at that address can change between uses of it ... so it stops the optimizer assuming the value hasn't changed between uses of that address.
Imagine the situation you have code that reads the port of a timer at an address. Then you do some other stuff not touching the port address and then you go an read the port again. Now if you are dealing with memory the two reads will have the same value as the code between the two reads didn't touch the port. So an optimizer might well conclude it can remove the second read and just hold the first read value. Only in reality the timer values ticks because it's hardware and so we need the second read to occur it can't be optimized. The same situation occurs in multitasking, memory that our own code didn't touch can change. So volatile is about making sure the optimizer doesn't shortcut stuff assuming just because the code hasn't touched it, that it hasn't changed. So any variable marked with volatile will have any action on that variable not subject to optimization.
Explicit is when you want the compiler to stop being smart and convert types for you and pretending it's GWBASIC
It used to happen mostly on class/object code that a constructor for example would take a string as a parameter. If you gave it an integer it would automatically know to convert the integer to a string, which is pretty cool sometimes. Other times it leads to a complete and utter bug because you didn't allow for it. So if you tell the compiler you want explicit it turns off the GWBASIC parser and stops the conversion it will throw an error instead.
Mutable is one you will rarely if ever need and if you do need it most of us will argue your code is badly organized or you are super lazy and dangerous. The better name for it would be cached or stencil playtime. So you have a constant or someone passes you in a constant, but you just want to change it I mean string "Drive A" is so close to "Drive B". You declare it mutable you can now play around with the constant it wont change the real constant just your local play copy. It's not something to encourage in that usage. The only real valid use of the directive is when you really are dealing with a real cache such as synchronization objects like mutexes & semaphores. It really exist solely for those unique situations and really shouldn't be abused.
Now I am being flippant so you actually take time to go read up on them properly but that is the basics.
In vino veritas
|
|
|
|
|
i have game application .exe and if someone target my .exe got crash (ddos attack)
i need to create dll file or application to can block or stop high traffic for port
any suggestion ?!
|
|
|
|
|
|
It's not something you deal with at your point as your internet provider will still attempt to deliver the messages to your single IP. So eventually your feed gets overloaded even if you are just reading the packet from the network card and disposing of them because you realize they are junk.
The easiest solution is sign up to a Content Delivery Network, they stop the data ever getting to your server. If you search that term plus your country I am sure you will find some companies to talk to and look at pricing for.
The other option you may want to consider if this is commercial is hiring virtual servers from a VM server farm. They can configure the Virtual server to whatever O/S you need and you run your program on their server. They usually do all the DDOS prevention stuff as part of the deal as they have that stuff already because they have hundreds if not thousands of servers.
In vino veritas
modified 6-Nov-16 11:08am.
|
|
|
|
|
thanks a lot bro .. i think that will be so expensive for me .. because i am Arabian .. with dollars will be higher per month ... i will try software can control traffic and filtering as i can .. if you have suggestion for software that will be awesome ... thanks again
|
|
|
|
|
I just started to learn C++, coming from a C# and Java background.
I like to use interfaces in my code. In C++ though they do not exist so instead I make structs with pure virtual methods. I'm interested in opinions on different conventions used.
My questions are:
1) From what I understand there is no difference between struct and class besides the default accessor, but it is common place to see struct being used when the class is of a smaller size. Therefore I decided as a convention to use struct when writing interfaces since the way struct is viewed by programmers more closely resembles an interface. Are there any other conventions on this issue or is my convention bad or could cause confusion in any way?
2) Since an interface only has pure virtual and provides no implementation (most of the times, default methods are now a thing in Java) I thought it would be logical to only make a header file for it, instead of making both a .cpp and a .h file. Since a .cpp file is supposed to have the implementation and the .h file is supposed to have the method prototypes. Again, are there any other conventions on this issue or is my convention bad or could cause confusion in any way?
Example:
ISayHello.h
struct IRender
{
virtual void render() = 0;
}
ImplementationExample.cpp
class Sprite : public IRender
{
public:
void render() override
{
}
}
What I have tried:
NOTE: My intention is to get the opinion of those with more experience on how my pattern works, if it has problems, and if there is any other convention on issue that my convention is addressing. If you think the question is off topic I would appreciate if you could redirect me to a better place to ask my question. This question for example was marked as off topic on the Code Review Stack Exchange, though in my opinion asking for review on a pattern you in your code is not off topic.
|
|
|
|
|
1. it's legal for a class to inherit from a struct, but it's unusual (i've never seen it done).
in my experience, structs are generally used in C++, like you said, for smaller objects - if they're used at all.
using a class for the interface is standard. having to type "public" isn't that big of a deal, and it avoids someone having to Google "can a class inherit from a struct".
2. your method is fine. personally, i would give the implementation it's own .h file.
FYI, what you're doing here is known as "PIMPL" in C++. there's a lot of info on it out there.
|
|
|
|
|
I tend to do exactly the same mainly because if I need I can transfer my C++ code easily to pure C, C# and into VHDL if working with FPGA's. Some will find our coding quirky because they have not come from that interface background but at the end of the day your code is tight and usually more portable to other languages when you need. Personally I think it's a good trait but those who only write in C++ will argue we aren't using the language to it's full ability.
Do you go the whole hog
I import multiple interfaces into things I never do C++ multiple inheritance at all. I also run my own form of delegates, mine is closer to C# that the standard C++ setup.
The final thing I do is probably very quirky to my embedded background, in that all my interfaces have an abstract event drive message function call set on them. Generally it will be unimplemented but the number of times it has saved my butt when I need complicated exchanges across the interfaces to synchronize them or often I use it for live debugging. Saves hours of time if you can connect to a locked program and actually look at the interface states. To do that you simply setup the event drive message pump in it's own thread and so you can actually push messages to get the interface states even though the program thread may be deadlocked.
The only downside is in team developments some will struggle to understand your code because it isn't the purest standard C++ form. On the couple of times I ever had that happen I just hide the interfaces inside a wrapper class, sort of where your sample is going. I normally don't hide the interfaces they just sit as exposed public on a class because they are an designed as a proper interface after all.
So like Chris said I am a PIMPL guy as well
In vino veritas
modified 4-Nov-16 14:57pm.
|
|
|
|
|
1. I generally use a struct if it's only going to have variables. All access has to public anyway since there are no accessor methods.
2. I also have only a .h file for interfaces. Sometimes I have multiple interfaces defined in one .h file.
|
|
|
|
|
One issue: I would define a virtual destructor for each interface. This allows you to delete an instance given a pointer to its interface.
If you are using c++ interfaces to implement something like COM, you may wish to disregard this advice.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
If I launch a non modal dialog from a CFormView, how can I know if the mouse leave the surface of the CNonModalDlg ? Preferable I should know inside of CNonModalDialog ... I override
OnMouseMove(UINT nFlags, CPoint point)
void CNonMOdalDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CPoint pt(point);
CRect rectDialog;
GetWindowRect(&rectDialog);
ScreenToClient(&rectDialog);
if(! rectDialog.PtInRect(pt))
TRACE("################################ooouttt\n");
CDialog::OnMouseMove(nFlags, point);
}
but when I leave the dialog surface, the TRACE are not signal me ...
|
|
|
|
|