1 pièce(s) jointe(s)
Refaire une fonction printf personnalisée
Bonjour,
Ce soir je vais commencer à développer une émulation de console de Microsoft ;
ca je sais faire.
Je voudrais refaire la fonction printf que je vais nommer par exemple "dwprintf" pour pouvoir plus tard afficher du texte dans ma console.
et ca ne compile pas du tout !
Comment fait t'on ?????
Je joint le projet qui utilise pour le moment printf et ca ne compile pas du tout !.
Merci
ma fonction à moi ci-dessous qui servira plus tard pour ma console microsoft emuler ;
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| int __cdecl dwsprintf (
char *string,
const char *format,
...
)
{
FILE str;
REG1 FILE *outfile = &str;
va_list arglist;
REG2 int retval;
_VALIDATE_RETURN( (format != NULL), EINVAL, -1);
#ifdef _COUNT_
_VALIDATE_RETURN( (count == 0) || (string != NULL), EINVAL, -1 );
#else /* _COUNT_ */
_VALIDATE_RETURN( (string != NULL), EINVAL, -1 );
#endif /* _COUNT_ */
va_start(arglist, format);
#ifndef _COUNT_
outfile->_cnt = MAXSTR;
#else /* _COUNT_ */
if(count>INT_MAX)
{
/* old-style functions allow any large value to mean unbounded */
outfile->_cnt = INT_MAX;
}
else
{
outfile->_cnt = (int)(count);
}
#endif /* _COUNT_ */
outfile->_flag = _IOWRT|_IOSTRG;
outfile->_ptr = outfile->_base = string;
retval = _output_l(outfile,format,NULL,arglist);
if (string == NULL)
return(retval);
#ifndef _SWPRINTFS_ERROR_RETURN_FIX
_putc_nolock('\0',outfile); /* no-lock version */
printf("%s\n",outfile->_ptr);
return(retval);
#else /* _SWPRINTFS_ERROR_RETURN_FIX */
if((retval >= 0) && (_putc_nolock('\0',outfile) != EOF))
return(retval);
string[0] = 0;
return -1;
#endif /* _SWPRINTFS_ERROR_RETURN_FIX */
} |
Citation:
1>e:\source\projet\recherche\resprintf\resprintf.cpp(23) : error C2065: 'REG1' : undeclared identifier
1>e:\source\projet\recherche\resprintf\resprintf.cpp(23) : error C2146: syntax error : missing ';' before identifier 'FILE'
1>e:\source\projet\recherche\resprintf\resprintf.cpp(23) : error C2065: 'outfile' : undeclared identifier
1>e:\source\projet\recherche\resprintf\resprintf.cpp(23) : error C2275: 'FILE' : illegal use of this type as an expression
1> l:\program files (x86)\microsoft visual studio 8\vc\include\stdio.h(69) : see declaration of 'FILE'
1>e:\source\projet\recherche\resprintf\resprintf.cpp(25) : error C2065: 'REG2' : undeclared identifier
1>e:\source\projet\recherche\resprintf\resprintf.cpp(25) : error C2144: syntax error : 'int' should be preceded by ';'
1>e:\source\projet\recherche\resprintf\resprintf.cpp(27) : error C2065: 'EINVAL' : undeclared identifier
1>e:\source\projet\recherche\resprintf\resprintf.cpp(27) : error C3861: '_VALIDATE_RETURN': identifier not found
1>e:\source\projet\recherche\resprintf\resprintf.cpp(32) : error C3861: '_VALIDATE_RETURN': identifier not found
1>e:\source\projet\recherche\resprintf\resprintf.cpp(37) : error C2227: left of '->_cnt' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(37) : error C2065: 'MAXSTR' : undeclared identifier
1>e:\source\projet\recherche\resprintf\resprintf.cpp(49) : error C2227: left of '->_flag' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(50) : error C2227: left of '->_ptr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(50) : error C2227: left of '->_base' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(52) : error C3861: '_output_l': identifier not found
1>e:\source\projet\recherche\resprintf\resprintf.cpp(58) : error C2227: left of '->_cnt' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(58) : error C2227: left of '->_ptr' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>e:\source\projet\recherche\resprintf\resprintf.cpp(59) : error C2227: left of '->_ptr' must point to class/struct/union/generic type
1> type is ''unknown-type''
Merci