本文整理汇总了C++中define函数的典型用法代码示例。如果您正苦于以下问题:C++ define函数的具体用法?C++ define怎么用?C++ define使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了define函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: define
std::string Version::preprocessorDefinition() const {
SmallString<64> define("-D__SWIFT_COMPILER_VERSION=");
llvm::raw_svector_ostream OS(define);
uint64_t versionConstant = 0;
auto NumComponents = Components.size();
if (NumComponents > 0)
versionConstant += Components[0] * 1000 * 1000 * 1000;
// Component 2 is not used.
if (NumComponents > 2)
versionConstant += Components[2] * 1000 * 1000;
if (NumComponents > 3)
versionConstant += Components[3] * 1000;
if (NumComponents > 4)
versionConstant += Components[4];
OS << versionConstant;
return OS.str().str();
}
开发者ID:6008,项目名称:swift,代码行数:20,代码来源:Version.cpp
示例2: main
int main(void){
char s[]="tudo puta e viado.";
clock_t Ti, Tf;
//scanf("%[^\n]",&s);
printf("%s\n",s );
Ti=clock();
string_inverte(s);
Tf=clock();
printf("%s\nem tempo: %f",s,(Tf-Ti) );
//usando pilha
char t[]="tudo puta e viado.";
lista pilha;
int cont=0;
char aux;
printf("\npilha\n");
Ti=clock();
define(&pilha);
while(t[cont]!='.'){
while(t[cont]!=' ' && t[cont]!='.'){
empilha(&pilha,t[cont]);
cont++;
}
while(pilha.total>0){
aux=desempilha(&pilha);
printf("%c",aux );
}
printf(" ");
if(t[cont]!='.'){
cont++;
}
}
Tf=clock();
printf("\npilha com tempo: %f\n",(Tf-Ti) );
return 0;
}
开发者ID:Gedankenn,项目名称:Algoritmos,代码行数:41,代码来源:inverte_frase.c
示例3: infile
void
SDFLoader::load()
{
std::ifstream infile(_filename);
std::string line;
while(std::getline(infile, line)) {
std::istringstream iss(line);
std::vector<std::string> tokens{std::istream_iterator<std::string>{iss},
std::istream_iterator<std::string>{}};
if (tokens.size() > 0 && tokens[0].substr(0, 1) == "#") {
continue;
}
if (tokens[0] == "render" && tokens.size() == 5) {
render(tokens);
} else if(tokens[0] == "define") {
define(tokens);
} else {
throw std::runtime_error("illegal sdf line");
}
}
}
开发者ID:Franky666,项目名称:programmiersprachen-raytracer,代码行数:21,代码来源:sdfloader.cpp
示例4: define
void UmlActivityParameter::html(Q3CString pfix, unsigned int rank, unsigned int level) {
define();
fw.write("<table><tr><td><div class=\"element\">Activity action pin <b>");
writeq(name());
fw.write("</b></div></td></tr></table>\n");
Q3CString s = defaultValue();
if (! s.isEmpty()) {
fw.write("<p>Default value :</p><ul>");
fw.write("<pre>\n");
writeq(s);
fw.write("</pre></ul>");
}
UmlPinParameter::html(pfix, rank, level);
unload(FALSE, FALSE);
}
开发者ID:SciBoy,项目名称:douml,代码行数:21,代码来源:UmlActivityParameter.cpp
示例5: get_next_line
int get_next_line(int const fd, char **line)
{
static t_var *get_in[MAX_FD];
if (fd >= MAX_FD || fd < 0 || line == NULL)
return (-1);
if (get_in[fd] && get_in[fd]->file_lecture == 0)
return (0);
if (!get_in[fd] && !define(&get_in[fd]))
return (-1);
while (get_in[fd]->file_lecture > 0 && !((return_line(get_in[fd]))))
{
while (get_in[fd]->tampon + BUFF_SIZE > get_in[fd]->len)
if (!add_memory_size(get_in[fd]))
return (-1);
get_in[fd]->file_lecture = read(fd,
get_in[fd]->memory + get_in[fd]->tampon, BUFF_SIZE);
get_in[fd]->tampon = get_in[fd]->tampon + get_in[fd]->file_lecture;
}
return (return_handle(&get_in[fd], get_in[fd], line));
}
开发者ID:ebouther,项目名称:21sh,代码行数:21,代码来源:get_next_line.c
示例6: main
int main(){
//declaração das variáveis
int i, ch, nl, np;
int *Rep = NULL;
bignum perm;
char frase[MAXDIGITS];
//Armazenado a frase digitada pelo usário
printf ("Por favor digite a frase desejada\n");
scanf (" %[^\n]", frase);
//A função define, define a quantidade de letras e de palavras contidas na frase, e as armazenas em nl e np respectivamente
define (frase, &nl, &np);
//A função reteptição armazena a quantidade de vezes que as letras (a-z) forma repetidas armazenado em um vetor
Rep = repeticao (frase);
//Controle caso a locação de memórias do vetor não for bem sucedida
if (!Rep){
printf ("Ocorreu um erro estranho\n");
return 0;
}
//Imprime os dados obitidos
printf("----------------\n");
printf ("A frase digitada foi: %s\n", frase);
printf ("Ela possui %d letras e %d palavras\n", nl, np);
printf("----------------\n");
printf ("Letras repetidas\n");
for (i=0; i<ALF; i++){
ch = 97;
if (Rep[i] != 0){
printf("%c -> %d repeticoes\n",ch+i, Rep[i]);
}
}
printf("----------------\n");
//A funcao calclando_com_corretas calcula qual é o numero de combianacoes exatas
calculando_com_corretas ( nl, np, Rep, &perm);
printf ("A frase digitada pode ser escrita de ");
//Exibindo o resultado
print_bignum (&perm);
printf ("maneiras\n");
//FIM DO PROGRAMA
return 0;
}
开发者ID:Carlos-Henreis,项目名称:trabalho-1-matematica-discreta,代码行数:40,代码来源:main.c
示例7: register_builtin_definitions
void register_builtin_definitions(void)
{
struct macro macro = {
{IDENTIFIER, NULL, 0},
OBJECT_LIKE,
0, /* parameters */
};
macro.name.strval = "__STDC_VERSION__";
macro.replacement = parse("199409L", ¯o.size);
define(macro);
macro.name.strval = "__STDC__";
macro.replacement = parse("1", ¯o.size);
define(macro);
macro.name.strval = "__STDC_HOSTED__";
macro.replacement = parse("1", ¯o.size);
define(macro);
macro.name.strval = "__LINE__";
macro.replacement = parse("0", ¯o.size);
define(macro);
macro.name.strval = "__x86_64__";
macro.replacement = parse("1", ¯o.size);
define(macro);
/* For some reason this is not properly handled by macros in musl. */
macro.name.strval = "__inline";
macro.replacement = parse(" ", ¯o.size);
define(macro);
macro.name.strval = "__FILE__";
macro.replacement = calloc(1, sizeof(*macro.replacement));
macro.replacement[0].token.token = STRING;
macro.replacement[0].token.strval = current_file.path;
macro.replacement[0].token.intval = 0;
define(macro);
register__builtin_va_end();
}
开发者ID:JamesLinus,项目名称:c-compiler,代码行数:42,代码来源:macro.c
示例8: org
int org(int size, char *label, char *op, int *errorPtr)
{
int newLoc;
bool backRef;
if (size)
NEWERROR(*errorPtr, INV_SIZE_CODE);
if (!*op) {
NEWERROR(*errorPtr, SYNTAX);
return NORMAL;
}
if (offsetMode) {
loc = locOffset; // restore loc used prior to Offset directive
offsetMode = false; // turn off offset mode
}
op = eval(op, &newLoc, &backRef, errorPtr);
if (*errorPtr < SEVERE && !backRef) {
NEWERROR(*errorPtr, INV_FORWARD_REF);
}
else if (*errorPtr < ERRORN) {
if (isspace(*op) || !*op) {
// Check for an odd value, adjust to one higher
if (newLoc & 1) {
NEWERROR(*errorPtr, ODD_ADDRESS);
newLoc++;
}
loc = newLoc;
// Define the label attached to this directive, if any
if (*label)
define(label, loc, pass2, true, errorPtr);
// Show new location counter on listing
listLoc();
}
else
NEWERROR(*errorPtr, SYNTAX);
}
return NORMAL;
}
开发者ID:flip-cyrus,项目名称:EASyCF51,代码行数:39,代码来源:DIRECTIV.CPP
示例9: ds
void
ds(int size, char *label, char *op, int *errorPtr)
{
int blockSize;
char backRef;
char *eval();
if (size == SHORT) {
NEWERROR(*errorPtr, INV_SIZE_CODE);
size = WORD;
} else if (!size)
size = WORD;
/* Move location counter to a word boundary and fix the listing if doing
DS.W or DS.L (but not if doing DS.B, so DS.B's can be contiguous) */
if ((size & (WORD | LONG)) && (loc & 1)) {
loc++;
listLoc();
}
/* Define the label attached to this directive, if any */
if (*label)
define(label, loc, pass2, errorPtr);
/* Evaluate the size of the block (in bytes, words, or longwords) */
op = eval(op, &blockSize, &backRef, errorPtr);
if (*errorPtr < SEVERE && !backRef) {
NEWERROR(*errorPtr, INV_FORWARD_REF);
return;
}
if (*errorPtr > SEVERE)
return;
if (!isspace(*op) && *op) {
NEWERROR(*errorPtr, SYNTAX);
return;
}
if (blockSize < 0) {
NEWERROR(*errorPtr, INV_LENGTH);
return;
}
loc += blockSize * size;
}
开发者ID:vfrico,项目名称:bsvc,代码行数:39,代码来源:directive.c
示例10: newEscape
void ShootEmUp::escapeCheck() {
if (_count321 != 0)
return;
if (_escapeCount > 0) {
_escapeCount--;
return;
}
// Escape_count = 0; now what ?
if (_escaping) {
if (_gotOut) {
newEscape();
_escaping = false;
_vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 4);
} else {
_vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 5);
_escapeCount = 20;
_gotOut = true;
define(_escapeStock * 90 + 20, 50, 24, 0, 2, 17, false, true); // Escaped!
gain(-10);
_hasEscaped[_escapeStock] = true;
_howManyHaveEscaped++;
if (_howManyHaveEscaped == 7) {
_vm->_graphics->seuDrawPicture(266, 90, 23);
_time = 0;
}
}
} else {
_escapeStock = getStockNumber(_vm->_rnd->getRandomNumber(6));
_escaping = true;
_gotOut = false;
_vm->_graphics->seuDrawPicture(_escapeStock * 90 + 20, 30, kStocks + 2); // Smiling!
_escapeCount = 200;
}
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:39,代码来源:shootemup.cpp
示例11: processline
int processline(const char *line,FILE *fd,FILE *fw)
{
int ret,i;
char *fields[10];
for(i=0;i<10;++i)
*(fields+i)=malloc(100);
split(line,fields,' ');
//if it is a macro call then expand
for(i=0;i<nami;++i)
{
ret=strcmp(namtab[i].name,fields[0]);
if(ret==0)
{
expand(line,fw);
return 1;
}
}
//if it is a macro definiton than , define it
ret=strcmp(fields[1],"MACRO");
if(ret==0)
{
define(line,fields[0],fd);
return 1;
}
//else write in into the output file
fprintf(fw,line);
fprintf(fw,"\n");
for(i=0;i<10;++i)
free(*(fields+i));
return 1;
}
开发者ID:akreddysoft,项目名称:CollegeCode,代码行数:39,代码来源:macro.c
示例12: libraryEnvironment
void
TestEval::eval_lambda()
{
EnvPtr env = libraryEnvironment();
ValuePtr value = eval(env, "((lambda (a b c) (+ a b c)) 1 2 3)");
CHECK("Integer type", value->isNumber() && value->isExact());
CHECK_EQUAL("Integer content", int, 6, value->vInt());
value = eval(env, "(define foo (lambda (a b c) (+ a b c)))\n(foo 1 2 3)\n");
CHECK("Integer type", value->isNumber() && value->isExact());
CHECK_EQUAL("Integer content", int, 6, value->vInt());
value = eval(env, "\n\
(define (accum n) (lambda (a) (set! n (+ a n)) n))\n \
(define foo (accum 5))\n\
(define bar (accum 100))\n\
(foo 10) ;Comment\n\
(bar 10)\n\
(foo 10)");
CHECK("Integer type", value->isNumber() && value->isExact());
CHECK_EQUAL("Integer content", int, 25, value->vInt());
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:22,代码来源:Eval.cpp
示例13: directive
static void
directive()
{
Tok *t;
char *dir;
t = ppnoexpand();
dir = t->v;
if(strcmp(dir, "include") == 0)
include();
else if(strcmp(dir, "define") == 0)
define();
else if(strcmp(dir, "if") == 0)
pif();
else if(strcmp(dir, "elseif") == 0)
elseif();
else if(strcmp(dir, "else") == 0)
pelse();
else if(strcmp(dir, "endif") == 0)
endif();
else
errorposf(&t->pos, "invalid directive %s", dir);
}
开发者ID:gitter-badger,项目名称:c,代码行数:23,代码来源:cpp.c
示例14: init_preprocess
void init_preprocess(void)
{
int i;
char *cp;
init_symtbl();
for (i = 0; predefs[i]; i++)
{
cp = copyofstr("1");
check_os_malloc(cp);
define(predefs[i], -1, (unsigned char *) cp, DEF_PREDEF);
}
init_include();
keep_comments = 0;
no_line_lines = 0;
do_at_ctrls = 0;
incldep = 0;
willbefirst = 1;
quote = 0;
ifstack = 0;
n_skipped_ifs = 0;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:23,代码来源:preprocess.c
示例15: main
int main(int argc, char** argv){
note n[6];
for(int i=0;i<6;i++){
n[i].start = 1.0;
n[i].length = 1.0;
}
define(n);
for(int i = 0;i<6;i++)
printf("%.2f\t%g\n", n[i].start, n[i].length);
return 0;
}
开发者ID:stephenhensley,项目名称:shensley-algo-cs,代码行数:23,代码来源:pPass.c
示例16: failError
//--------------------------------------------------------
// FAIL directive (ck)
// Displays the message following the FAIL directive.
// Increments the Assemblers error count just like any other error.
//
int failError(int size, char *label, char *message, int *errorPtr)
{
if (size) { // if .size code specified
NEWERROR(*errorPtr, INV_SIZE_CODE); // error, invalid size code
return NORMAL;
}
// Define the label attached to this include directive, if any
if (*label)
define(label, loc, pass2, true, errorPtr);
if (!*message) // if no message
sprintf(buffer, "ERROR: Unspecified user defined error. \n");
else {
strncpy(buffer, message, 254);
buffer[255] = '\0';
}
NEWERROR(*errorPtr, FAIL_ERROR);
// Automatically listed because it's treated like an error
return NORMAL;
}
开发者ID:flip-cyrus,项目名称:EASyCF51,代码行数:28,代码来源:DIRECTIV.CPP
示例17: set
int set(int size, char *label, char *op, int *errorPtr)
{
int value;
int error;
bool backRef;
symbolDef *symbol;
if (size)
NEWERROR(*errorPtr, INV_SIZE_CODE);
if (!*op) {
NEWERROR(*errorPtr, SYNTAX);
return NORMAL;
}
error = OK;
op = eval(op, &value, &backRef, errorPtr);
// if (*errorPtr < SEVERE && !backRef) { // ck 4-18-03
// NEWERROR(*errorPtr, INV_FORWARD_REF);
// }
// else
if (*errorPtr < ERRORN) // ck 4-18-03
if (isspace(*op) || !*op)
if (!*label) {
NEWERROR(*errorPtr, LABEL_REQUIRED);
} else {
error = OK;
symbol = define(label, value, pass2, false, &error); // ck 4-18-03
symbol->flags |= REDEFINABLE;
if (pass2 & listFlag) {
sprintf(listPtr, "=%08lX ", value);
listPtr += 10;
}
}
else
NEWERROR(*errorPtr, SYNTAX);
return NORMAL;
}
开发者ID:flip-cyrus,项目名称:EASyCF51,代码行数:37,代码来源:DIRECTIV.CPP
示例18: section
/***********************************************************************
* SECTION directive (ck)
***********************************************************************/
int section(int size, char *label, char *op, int *errorPtr)
{
int value;
int newLoc;
bool backRef = true;
if (size)
NEWERROR(*errorPtr, INV_SIZE_CODE);
if (offsetMode) {
loc = locOffset; // restore loc used prior to Offset directive
offsetMode = false; // turn off offset mode
}
if (*op) { // if section number
eval(op, &value, &backRef, errorPtr); // evaluate section number
if (*errorPtr < SEVERE && !backRef) {
NEWERROR(*errorPtr, INV_FORWARD_REF);
}
else if (*errorPtr < ERRORN) {
if (value < 0 || value > 15) { // if illegal section number
NEWERROR(*errorPtr, SYNTAX);
return NORMAL;
}
sectionLoc[sectI] = loc; // save current loc to current section
loc = sectionLoc[value]; // set loc to new section
sectI = value; // new section number
// Show new location counter on listing
listLoc();
} else {
NEWERROR(*errorPtr, SYNTAX);
}
} else if (!*label) // else no section number if no label
NEWERROR(*errorPtr, LABEL_REQUIRED);
if (*label) // if label
define(label, sectI, pass2, true, errorPtr); // define to sectI
return NORMAL;
}
开发者ID:flip-cyrus,项目名称:EASyCF51,代码行数:40,代码来源:DIRECTIV.CPP
示例19: MakeHeaderGuard
BString
MakeHeaderGuard(const char *name)
{
BString define(name);
define.ReplaceSet(" .-","_");
// Normally, we'd just put something like :
// define[i] = toupper(define[i]);
// in a loop, but the BString defines for Zeta are screwed up, so we're going to have to
// work around them.
char *buffer = define.LockBuffer(define.CountChars() + 1);
for (int32 i = 0; i < define.CountChars(); i++)
buffer[i] = toupper(buffer[i]);
define.UnlockBuffer();
BString guard;
guard << "#ifndef " << define << "\n"
<< "#define " << define << "\n"
"\n"
"\n"
"\n"
"#endif\n";
return guard;
}
开发者ID:jscipione,项目名称:Paladin,代码行数:24,代码来源:Globals.cpp
示例20: eval
Cell eval(Cell exp, Cell env) {
if (is_self_evaluating(exp)) {
return exp;
} else if (is_atom(exp)) {
return lookup(exp, env);
} else if (is_tagged(exp, atom("define"))) {
return define(car(cdr(exp)), eval(car(cdr(cdr(exp))), env), env);
} else if (is_tagged(exp, atom("set!"))) {
return set(car(cdr(exp)), eval(car(cdr(cdr(exp))), env), env);
} else if (is_tagged(exp, atom("if"))) {
Cell cond = eval(car(cdr(exp)), env);
if (is_atom(cond) && is_eq(cond, atom("#f"))) {
exp = car(cdr(cdr(cdr(exp))));
} else {
exp = car(cdr(cdr(exp)));
}
return eval(exp, env);
} else if (is_tagged(exp, atom("vau"))) {
return procedure(exp, env);
} else if (is_pair(exp)) {
Cell proc = eval(car(exp), env);
if (is_primitive(proc)) {
return (proc->primitive)(eval_operands(cdr(exp), env));
} else if (is_procedure(proc)) {
Cell src = car(proc);
Cell e = car(cdr(cdr(src)));
Cell para = cons(e, cons(car(cdr(src)), null));
Cell args = cons(env, cons(cdr(exp), null));
Cell body = car(cdr(cdr(cdr(src))));
return eval(body, extend_env(para, args, cdr(proc)));
}
}
fprintf(stderr, "eval illegal state\n");
return atom("#<void>");
}
开发者ID:keleshev,项目名称:little-scheme,代码行数:36,代码来源:little.c
注:本文中的define函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论