|
Sory i thought i posted it
#include unistd.h
thanx
-oam-
|
|
|
|
|
Are you developing on UNIX? .. I Tlooks like it's a UNIX specific header file
see: [^]
for my google results... I also found this http://aegis.sourceforge.net/doxygen-html/unistd_8h-source.html[^] which is *A* uninstd.h file .. but i have doubts that it's the one specific to the application you are trying to compile ....
IF you can provide details about the application / source / where it was obtained from / what platform your working on etc... I will do my bes to help you out ...
Regards
qcha0s
|
|
|
|
|
Question is, what good is a header file to him anyhow ? I suspect he's got code that includes it, and he has no idea that the header file needs at least a lib file to link to before it's worth anything.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
infact i wanted to compile this code below but now i am working hand in hand with unix machines. But now i wanted to try this application on windows
<br />
#include <stdio.h> <br />
#include <stdlib.h> <br />
#include <unistd.h> <br />
#include <string.h> <br />
<br />
main()<br />
{<br />
char *restart_name, *restart, old_restart_name[BUFSIZ];<br />
FILE *restart_file;<br />
int n;<br />
<br />
<br />
<br />
if (! (restart = getenv ("RSAVE_RESTART"))) {<br />
printf ("Starting a new run.\n");<br />
n = 0;<br />
}<br />
else {<br />
if (! (restart_name = getenv ("RSAVE_CHECKFILE"))) {<br />
fprintf (stderr, "error: no checkpoint file for the restart job\n");<br />
exit (1);<br />
}<br />
else {<br />
printf ("Restarting the job from %s.\n", restart_name);<br />
if (! (restart_file = fopen(restart_name, "r"))) {<br />
perror (restart_name);<br />
exit (2);<br />
}<br />
else {<br />
if (! (fscanf (restart_file, "%d", &n) > 0)) {<br />
fprintf (stderr, "%s: input file format error\n", restart_name);<br />
exit (3);<br />
}<br />
else {<br />
fclose (restart_file);<br />
}<br />
} <br />
}<br />
}<br />
<br />
printf ("n = %d\n", n);<br />
printf ("\tcomputing ... "); fflush (stdout);<br />
sleep (5);<br />
n++;<br />
printf ("done.\n");<br />
printf ("n = %d\n", n);<br />
<br />
if (! (restart_name = getenv ("RSAVE_CHECKFILE"))) {<br />
printf ("checkpointing not requested, exiting...\n");<br />
exit (0);<br />
}<br />
else {<br />
if (restart) {<br />
strcpy (old_restart_name, restart_name);<br />
strcat (old_restart_name, ".old");<br />
printf ("renaming old restart file to %s\n", old_restart_name);<br />
if (0 > rename (restart_name, old_restart_name)) {<br />
perror (old_restart_name);<br />
exit (4);<br />
}<br />
}<br />
printf ("saving data on %s\n", restart_name);<br />
if (! (restart_file = fopen (restart_name, "w"))) {<br />
perror (restart_name);<br />
exit (5);<br />
}<br />
else {<br />
fprintf (restart_file, "%d\n", n);<br />
fclose (restart_file);<br />
}<br />
}<br />
exit (0);<br />
}<br />
<br />
-oam-
|
|
|
|
|
What do you intend to do with it ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I am running an application on windows from a unix machine and it was looking for this header but then i didn't want to go to the unix machine
-oam-
|
|
|
|
|
OK - as I thought. You're more than a little lost here. A header file describes functionality that needs to be provided either in matching .cpp files, or in a library file. The compiler is asking for the header file now, but if you provide it, you will get linker errors from here to sundown, because you will have a file that promises the compiler that you'll tell it how to impliment functions you're describing now, sometime later. You will not meet that promise, and so your code will still not work ( unless this is an inline class that's all in the .h file, implimentation as well as interface, but that seems unlikely ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Did you check the code i sent there
headers are
#include <stdio.h> /* has definitions of printf, fprintf, fopen, fscanf,
fclose, fflush, perror, rename and BUFSIZ */
#include <stdlib.h> /* has definitions of getenv and exit */
#include <unistd.h> /* has definition of sleep */
#include <string.h> /* has definitions of strcpy and strcat */
therefore i thought the header file will take care of the definition of sleep and that there header file is standard like some headers files that you can get them from somewhere and use them
-oam-
|
|
|
|
|
mpapeo wrote:
Did you check the code i sent there
No, you need to check 'Do not treat <'s as HTML tags' so I can see this code, for what it's worth
mpapeo wrote:
therefore i thought the header file will take care of the definition of sleep
It will take care of the 'definition', that is, it will define the interface, the functions/structs/classes provided elsewhere. It won't give you the code you need to make those things work. The standard library headers, such as iostream, define exactly that, and have corresponding .cpp files which are in directories that your compiler includes in it's searches by default. So they get compiled and linked into your project, no problem. You can't just add other header files to do the same thing, without making sure you are linking to a library, or have the implimentation files available to the compiler also.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Are you just looking for a header file that will support Sleep?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
My collegue have ported some Project from Unix enviornment to windows enviornment.
Here is What i found in unistd.h
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif /* _UNISTD_H */
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Well i was interested in the code i sent before as it was running in unix but it is possible run it on windows platform. I wanted to use that code somewhere in one of my programs
Any help pliz
-oam-
|
|
|
|
|
Christian Graus wrote:
A header file describes functionality that needs to be provided either in matching .cpp files, or in a library file.
True, but not always. Some of them have typedef and struct declarations only. I've no idea what mpapeo is looking for, however.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Some of them have typedef and struct declarations only
Yeah, and some contain the entire class ( can't they ? ). I said as much before, but in restating it, I was less careful
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've generally found that you can just delete this line and it will work under Windows. Don't quote me on that though, it may not work at all.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello, I'm parsing an XML on a deskband client using SAX: Here is the code:
<br />
CoInitialize(NULL); <br />
ISAXXMLReader* pRdr = NULL;<br />
<br />
HRESULT hr = CoCreateInstance(__uuidof(SAXXMLReader), NULL, CLSCTX_ALL,<br />
__uuidof(ISAXXMLReader), (void **)&pRdr);<br />
<br />
if(!FAILED(hr)) <br />
{<br />
hr = pRdr->putContentHandler(&m_whizzWnd->m_whizzHandler);<br />
<br />
VARIANT var;<br />
VariantInit(&var);<br />
V_BSTR(&var) = SysAllocString(wresp.c_str());<br />
V_VT(&var) = VT_BSTR;<br />
<br />
hr = pRdr->parse(var);<br />
<br />
VariantClear(&var);<br />
<br />
pRdr->Release();<br />
} else {<br />
MessageBox(NULL, TEXT("Error"), NULL, MB_ICONASTERISK);<br />
}<br />
<br />
CoUninitialize();<br />
The problem is that I have reports of memory leaks generated by that code. I'm detecting the memory leaks with the following code after the last include in all my cpp files:
<br />
#include <crtdbg.h><br />
<br />
#ifdef _DEBUG<br />
#define new new(_NORMAL_BLOCK, THIS_FILE, __LINE__)<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
And with the following class (I create an instance to begin test and get a memory leak report when the instance is deleted).
<br />
class FindMemoryLeaks<br />
{<br />
_CrtMemState m_checkpoint;<br />
public:<br />
<br />
FindMemoryLeaks()<br />
{<br />
_CrtMemCheckpoint(&m_checkpoint);<br />
};<br />
<br />
~FindMemoryLeaks()<br />
{<br />
_CrtMemState checkpoint;<br />
_CrtMemCheckpoint(&checkpoint);<br />
_CrtMemState diff;<br />
_CrtMemDifference(&diff, &m_checkpoint, &checkpoint);<br />
_CrtMemDumpStatistics(&diff);<br />
_CrtMemDumpAllObjectsSince(&diff);<br />
};<br />
};<br />
Any way, I have two kinds of memory leaks reports, the nice ones (no problem because I have file/line number)
<br />
Data: << r e s p o n s > 3C 00 72 00 65 00 73 00 70 00 6F 00 6E 00 73 00 <br />
c:\eclipse\workspace\gxclientcpp\gxclientcpp\gxclient\deskband\cwhizzmanager.cpp(348) : {267} normal block at 0x00D97FE0, 4 bytes long.<br />
And the ugly ones, because they DON'T report file/line number :
<br />
Data: <A 5 0 0 p l u s > 41 00 35 00 30 00 30 00 70 00 6C 00 75 00 73 00 <br />
{460} normal block at 0x00D9F5F8, 32 bytes long.<br />
The funny thing is that the A500plus comes in a character and in an attribute of an XML tag
The Content handler seems to be ok:
<br />
void MyContent::GetSafeValue(wstring &target, ISAXAttributes *attrs, LPTSTR name) {<br />
size_t len1;<br />
int len2;<br />
StringCchLength(name, STRSAFE_MAX_CCH, &len1);<br />
LPTSTR value;<br />
<br />
if (attrs->getValueFromQName(name, len1, &value, &len2) == E_INVALIDARG) {<br />
target = TEXT("");<br />
} else {<br />
target = value;<br />
SysFreeString(value);<br />
}<br />
}<br />
<br />
HRESULT STDMETHODCALLTYPE MyContent::startElement(wchar_t __RPC_FAR *pwchNamespaceUri,<br />
int cchNamespaceUri, wchar_t __RPC_FAR *pwchLocalName,<br />
int cchLocalName, wchar_t __RPC_FAR *pwchRawName,<br />
int cchRawName, ISAXAttributes __RPC_FAR *pAttributes)<br />
{<br />
m_characters.clear();
<br />
if (!wcscmp(pwchRawName, TEXT("response"))) {<br />
wstring boolStr;<br />
<br />
GetSafeValue(boolStr, pAttributes, TEXT("hasPrev"));<br />
<br />
if (!wcscmp(boolStr.c_str(), TEXT("true"))) {<br />
m_hasPrev = TRUE;<br />
} else {<br />
m_hasPrev = FALSE;<br />
}<br />
<br />
GetSafeValue(boolStr, pAttributes, TEXT("hasNext"));<br />
<br />
if (!wcscmp(boolStr.c_str(), TEXT("true"))) {<br />
m_hasNext = TRUE;<br />
} else {<br />
m_hasNext = FALSE;<br />
}<br />
}<br />
return S_OK;<br />
}<br />
<br />
HRESULT STDMETHODCALLTYPE MyContent::characters(wchar_t __RPC_FAR *pwchChars, int cchChars)<br />
{<br />
wstring aux(pwchChars);<br />
m_characters.append(aux.substr(0, cchChars));<br />
return S_OK;<br />
}<br />
Believe me, there seems to be nothing extrange there (no more than the GetSafeValue), and there are no obvious memory leaks (And the file is a little big to post it here)
If any one sees the mistake I would be grateful for ever
Regards, Demián
|
|
|
|
|
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
<br />
void ShowExportTemplatePreview(HWND hwnd)<br />
{<br />
<br />
HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));<br />
<br />
if(hinstMSHTML)<br />
{<br />
SHOWHTMLDIALOGFN *pfnShowHTMLDialog;<br />
pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog"));<br />
<br />
if(pfnShowHTMLDialog)<br />
{<br />
char szTemplatePreview[MAX_PATH];<br />
wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory);<br />
<br />
WCHAR wcTemplatePreview[MAX_PATH];<br />
<br />
MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), <br />
wcTemplatePreview, MAX_PATH);<br />
<br />
IMoniker *pURLMoniker;<br />
CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker);<br />
<br />
if (pURLMoniker)<br />
{<br />
BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes");<br />
<br />
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);<br />
<br />
SysFreeString(bstrOptions);<br />
<br />
pURLMoniker->Release();<br />
}<br />
}<br />
<br />
FreeLibrary(hinstMSHTML);<br />
}<br />
}<br />
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to:
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);
But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance.
|
|
|
|
|
You haven't said what the error is?
georgiek50 wrote:
We have pinpointed the problem to:
What problem - besides "not working"?
You aren't testing a) if the file exists, b) whether an appropriate version of MSHTML is being used, c) what ShowHTMLDialog() returns, d) whether the hWnd is valid.
FYI you should use the pre and code links on the Formatting bar below the mssage area when posting code.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
GetLastError() returns 0 and I don't know specifically which function to call to get this type of error (I'm very new to this stuff and can't find it in MSDN)
Not working means the dialog isn't opening. The file is there, MSHTML.dll is being loaded as well.
Thanks for the help.
|
|
|
|
|
|
Check your return values and init your pointers to NULL. Specifically, if CreateURLMoniker() fails, you don't look at its retval and pMoniker will be left as uninitialized (but non-zero) garbage, which you will treat as success.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
CreateURLMoniker returns S_OK. The only reason I know that it is failing at the specific line is that the HRESULT returned by ShowHTMLDialog != S_OK (I have tested all other return values). I guess the most important question from here is to find what error code exactly the function returns. That is what I can't find documentation on.
Thanks for the help.
|
|
|
|
|
I have a tree containing a large number of items, each leaf item has a PARAM attached to it ( pointer to its data )
Is there a better way to highlight items in the tree than just looping thru all items in it ?
for example, I have something like (pseudo code):
...
for ( myData; ++myData )
{
tree.highlightItem( myData, TVI_ROOT );
}
...
myTree::highlightItem( myDataType myData, HTREEITEM hItem );
{
HTREEITEM hCurrent = hItem;
while( hCurrent )
{
HTREEITEM hChild = GetChildItem( hCurrent );
myDataType* pData = (myDataType*)GetItemData( hCurrent );
if ( pData == myData )
{
SetItemState( hCurrent, TVIS_SELECTED, TVIS_SELECTED );
}
if( highlightItem( hChild, myData ) )
return true;
hCurrent = GetNextItem( hCurrent, TVGN_NEXT );
}
}
I can set the root item as close as possible to the leaf I'm looking for, eliminating as much recursion as possible, but if a sub-tree contains a very large amount of items,
Is there a better solution ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I would have thought iterating the (MS) tree would be too slow and isn't something you would typically want to do. Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
IMO this is one of big problems using many MS controls as you need to double up on where data is stored and transfer stuff back and forth. It is far better if the control simply displays your data wherever and however it is stored. But I diverse.
The MS Tree Ctrl isn't all that fast, especially with large trees. Which is why I don't use it.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
I tried this, it works when the tree gets updated when the selected state of data is modified external of thh tree, but I have problems when changing the select items from within the tree itself.
Will keep trying to find what wrong with this.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|