本文整理汇总了C++中xprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ xprintf函数的具体用法?C++ xprintf怎么用?C++ xprintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: branch_drtom
//.........这里部分代码省略.........
{ stat = glp_get_row_stat(mip, k);
dk = glp_get_row_dual(mip, k);
}
else
{ stat = glp_get_col_stat(mip, k-m);
dk = glp_get_col_dual(mip, k-m);
}
/* if the current basis is dual degenerate, some reduced
costs which are close to zero may have wrong sign due to
round-off errors, so correct the sign of d[k] */
switch (T->mip->dir)
{ case GLP_MIN:
if (stat == GLP_NL && dk < 0.0 ||
stat == GLP_NU && dk > 0.0 ||
stat == GLP_NF) dk = 0.0;
break;
case GLP_MAX:
if (stat == GLP_NL && dk > 0.0 ||
stat == GLP_NU && dk < 0.0 ||
stat == GLP_NF) dk = 0.0;
break;
default:
xassert(T != T);
}
/* now knowing the change of x[k] and its reduced cost d[k]
we can compute the corresponding change in the objective
function delta Z = new Z - old Z = d[k] * delta x[k];
note that due to Tomlin's modification new Z can be even
worse than in the adjacent basis */
delta_z = dk * delta_k;
skip: /* new Z is never better than old Z, therefore the change
delta Z is always non-negative (in case of minimization)
or non-positive (in case of maximization) */
switch (T->mip->dir)
{ case GLP_MIN: xassert(delta_z >= 0.0); break;
case GLP_MAX: xassert(delta_z <= 0.0); break;
default: xassert(T != T);
}
/* save the change in the objective fnction for down- and
up-branches, respectively */
if (kase < 0) dz_dn = delta_z; else dz_up = delta_z;
}
/* thus, in down-branch no integer feasible solution can be
better than Z + dz_dn, and in up-branch no integer feasible
solution can be better than Z + dz_up, where Z is value of
the objective function in the current basis */
/* following the heuristic by Driebeck and Tomlin we choose a
column (i.e. structural variable) which provides largest
degradation of the objective function in some of branches;
besides, we select the branch with smaller degradation to
be solved next and keep other branch with larger degradation
in the active list hoping to minimize the number of further
backtrackings */
if (degrad < fabs(dz_dn) || degrad < fabs(dz_up))
{ jj = j;
if (fabs(dz_dn) < fabs(dz_up))
{ /* select down branch to be solved next */
next = GLP_DN_BRNCH;
degrad = fabs(dz_up);
}
else
{ /* select up branch to be solved next */
next = GLP_UP_BRNCH;
degrad = fabs(dz_dn);
}
/* save the objective changes for printing */
dd_dn = dz_dn, dd_up = dz_up;
/* if down- or up-branch has no feasible solution, we does
not need to consider other candidates (in principle, the
corresponding branch could be pruned right now) */
if (degrad == DBL_MAX) break;
}
}
/* free working arrays */
xfree(ind);
xfree(val);
/* something must be chosen */
xassert(1 <= jj && jj <= n);
#if 1 /* 02/XI-2009 */
if (degrad < 1e-6 * (1.0 + 0.001 * fabs(mip->obj_val)))
{ jj = branch_mostf(T, &next);
goto done;
}
#endif
if (T->parm->msg_lev >= GLP_MSG_DBG)
{ xprintf("branch_drtom: column %d chosen to branch on\n", jj);
if (fabs(dd_dn) == DBL_MAX)
xprintf("branch_drtom: down-branch is infeasible\n");
else
xprintf("branch_drtom: down-branch bound is %.9e\n",
lpx_get_obj_val(mip) + dd_dn);
if (fabs(dd_up) == DBL_MAX)
xprintf("branch_drtom: up-branch is infeasible\n");
else
xprintf("branch_drtom: up-branch bound is %.9e\n",
lpx_get_obj_val(mip) + dd_up);
}
done: *_next = next;
return jj;
}
示例2: bcm6352_enet_write
/* --------------------------------------------------------------------------
Name: bcm6352_enet_write
Purpose: Sends a data buffer.
-------------------------------------------------------------------------- */
static int bcm6352_enet_write(cfe_devctx_t *ctx,iocb_buffer_t *buffer)
{
int copycount;
unsigned int srclen;
unsigned char *dstptr;
unsigned char *srcptr;
bcm6352enet_softc *softc = (bcm6352enet_softc *) ctx->dev_softc;
volatile DmaChannel *txDma = softc->txDma;
/* ============================= ASSERTIONS ============================= */
if( ctx == NULL ) {
xprintf( "No context\n" );
return -1;
}
if( buffer == NULL ) {
xprintf( "No dst buffer\n" );
return -1;
}
if( buffer->buf_length > ENET_MAX_BUF_SIZE ) {
xprintf( "src buffer too large.\n" );
xprintf( "size is %d\n", buffer->buf_length );
return -1;
}
if( softc == NULL ) {
xprintf( "softc has not been initialized.\n" );
return -1;
}
/* ====================================================================== */
/******** Convert header to Broadcom's special header format. ********/
dstptr = softc->txBufPtr;
srcptr = buffer->buf_ptr;
srclen = buffer->buf_length;
memcpy( dstptr, srcptr, ETH_ALEN * 2 );
dstptr += ETH_ALEN * 2;
srcptr += ETH_ALEN * 2;
*((uint16_t *)dstptr) = BRCM_TYPE;
dstptr += 2;
if( srclen < 60 - 6 - 8 ) {
*((uint16_t *)dstptr) = (uint16_t)60;
} else {
*((uint16_t *)dstptr) = (uint16_t)(srclen + 6 + 8);
}
dstptr += 2;
*((uint16_t *)dstptr) = (uint16_t)MANAGEMENT_PORT;
dstptr += 2;
copycount = srclen - ETH_ALEN * 2;
memcpy( dstptr, srcptr, copycount );
if( srclen < 60 ) {
dstptr += copycount;
memset( dstptr, 0, 60 - srclen );
txDma->length = 66;
} else {
txDma->length = srclen + 6;
}
/* Set status of DMA buffer to be transmitted. */
txDma->bufStat = DMA_SOP | DMA_EOP | DMA_APPEND_CRC | DMA_OWN;
/* Enable DMA for this channel. */
softc->txDma->cfg |= DMA_ENABLE;
/* poll the dma status until done. */
while( (txDma->bufStat & DMA_OWN) == 0 )
;
txDma->bufStat = 0;
return 0;
}
示例3: main
void main() {
int n;
xprintf("a\n%d\n%d\n%10d\n%010d\n%u\n%x\n%c\n%s\n%n", 42, -10, 1, 5, 1234,
0xabcdef5, 'c', "Hello", &n);
xprintf("%d\n", n);
}
示例4: main
int main(void)
{
int LogOn = 0;
int ComOn = 0;
int dT;
int16_t data[32];
uint32_t x;
UINT cnt;
InitSystemTick();
InitGPIO();
InitTimer();
STM_EVAL_LEDOn(LED4);
InitUART(115200);
InitPressureSensor();
InitFlowMeter();
InitAccAndMag();
InitGyro();
STM_EVAL_LEDOn(LED7); // zapnem LED7 - zelena
Delta_us();
while(1)
{
// sample period is time elapsed since previous sampling of sensors
sampleSensors(a,m,g);
// update timebase for next time
dT = Delta_us();
samplePeriod = 0.000001f * dT;
// convert gyro deg/s to rad/s
imuDegToRadV3(g);
// update AHRS
MadgwickFullAHRSUpdate(g, a, m, samplePeriod, quaternion);
if (LogOn) {
sprintf(text, "%5d%6d%6d%6d%7d%7d%7d%5d%5d%5d\r\n",
dT,
aRawData[0], aRawData[1], aRawData[2],
gRawData[0], gRawData[1], gRawData[2],
mRawData[0], mRawData[1], mRawData[2]);
f_write(&File, text, strlen(text), &cnt);
}
if(STM_EVAL_PBGetState(BUTTON_USER)) { // zmena rezimu vystupu
if (LogOn) {
// Stop logdata
LogOn = 0;
STM_EVAL_LEDOff(LED5); // zapnem LED7 - zelena
if (f_close(&File) == 0)
xprintf("Stop login data.\n\r");
else
xprintf("Error write datafile.\n\r");
} else {
// Start logdata
if (newFile() == 0)
xprintf("Start login data.\n\r");
else
xprintf("Error create datafile.\n\r");
STM_EVAL_LEDOn(LED5); // zapnem LED7 - zelena
LogOn = 1;
}
}
if (ComOn) {
data[0] = dT;
data[1] = aRawData[0];
data[2] = aRawData[1];
data[3] = aRawData[2];
data[4] = gRawData[0];
data[5] = gRawData[1];
data[6] = gRawData[2];
data[7] = mRawData[0];
data[8] = mRawData[1];
data[9] = mRawData[2];
data[10] = 0x8080;
SendDataUART((uint8_t*) data, 22);
}
if (IsReceiveUART()) {
if (ReadByteUART() == 's') {
STM_EVAL_LEDOn(LED10); // zapnem LED7 - zelena
ComOn = 1;
} else {
STM_EVAL_LEDOff(LED10); // zapnem LED7 - zelena
ComOn = 0;
}
}
/*
if (x = GetFlowMeter()) {
printf("Flow: %d\n\r", x);
}
*/
}
}
示例5: app_hit10
void app_hit10() { // 10秒あてゲーム
for (;;) {
playMML("L8ER8EG16E16");
ux_btn();
for (;;) {
FILL("afeaaa0067252577"); // title
FLUSH();
if (ux_btn())
break;
}
playMML("C");
FILL(PTN_3);
FLUSH();
WAIT(1000);
playMML("C");
FILL(PTN_2);
FLUSH();
WAIT(1000);
playMML("C");
FILL(PTN_1);
FLUSH();
WAIT(1000);
playMML("G2");
FILL(PTN_GO);
FLUSH();
WAIT(1000);
CLS(1);
systick = 0;
int cnt = 0;
int bkbtn = 0;
for (;;) {
int btn = ux_btn();
if (btn && !bkbtn) {
playMML("A4");
CLS(0);
break;
}
bkbtn = btn;
setMatrix2(buf);
wait(10);
}
unsigned int score = (10 * 100000 - systick) / 1000;
if (score < 0)
score = -score;
playMML("L8CEG");
FILL("00c9aaacacaaaa69"); // ok
xprintf("%d\n", systick);
xprintf("%d\n", score);
/*
for (int i = 0;; i++) {
int n = time % 10;
time /= 10;
if (time == 0)
break;
FILL(PTN_NUM[n]);
FLUSH();
WAIT(500);
}
*/
FILL(PTN_NUM[score / 10]);
PSET(6, 6);
FLUSH();
WAIT(1000);
FILL(PTN_NUM[score % 10]);
FLUSH();
WAIT(1000);
FLUSH();
WAIT(1000);
}
}
示例6: command_extra
bool command_extra(uint8_t code)
{
uint32_t t;
uint16_t b;
switch (code) {
case KC_H:
case KC_SLASH: /* ? */
print("\n\n----- Bluetooth RN-42 Help -----\n");
print("i: RN-42 info\n");
print("b: battery voltage\n");
print("Del: enter/exit RN-42 config mode\n");
print("Slck: RN-42 initialize\n");
#if 0
print("1-4: restore link\n");
print("F1-F4: store link\n");
#endif
print("p: pairing\n");
if (config_mode) {
return true;
} else {
print("u: toggle Force USB mode\n");
return false; // to display default command help
}
case KC_P:
pairing();
return true;
#if 0
/* Store link address to EEPROM */
case KC_F1:
store_link(RN42_LINK0);
return true;
case KC_F2:
store_link(RN42_LINK1);
return true;
case KC_F3:
store_link(RN42_LINK2);
return true;
case KC_F4:
store_link(RN42_LINK3);
return true;
/* Restore link address to EEPROM */
case KC_1:
restore_link(RN42_LINK0);
return true;
case KC_2:
restore_link(RN42_LINK1);
return true;
case KC_3:
restore_link(RN42_LINK2);
return true;
case KC_4:
restore_link(RN42_LINK3);
return true;
#endif
case KC_I:
print("\n----- RN-42 info -----\n");
xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
xprintf("force_usb: %X\n", force_usb);
xprintf("rn42: %s\n", rn42_rts() ? "OFF" : (rn42_linked() ? "CONN" : "ON"));
xprintf("rn42_autoconnecting(): %X\n", rn42_autoconnecting());
xprintf("config_mode: %X\n", config_mode);
xprintf("USB State: %s\n",
(USB_DeviceState == DEVICE_STATE_Unattached) ? "Unattached" :
(USB_DeviceState == DEVICE_STATE_Powered) ? "Powered" :
(USB_DeviceState == DEVICE_STATE_Default) ? "Default" :
(USB_DeviceState == DEVICE_STATE_Addressed) ? "Addressed" :
(USB_DeviceState == DEVICE_STATE_Configured) ? "Configured" :
(USB_DeviceState == DEVICE_STATE_Suspended) ? "Suspended" : "?");
xprintf("battery: ");
switch (battery_status()) {
case FULL_CHARGED: xprintf("FULL"); break;
case CHARGING: xprintf("CHARG"); break;
case DISCHARGING: xprintf("DISCHG"); break;
case LOW_VOLTAGE: xprintf("LOW"); break;
default: xprintf("?"); break;
};
xprintf("\n");
xprintf("RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
xprintf("VBUS: %X\n", USBSTA&(1<<VBUS));
t = timer_read32()/1000;
uint8_t d = t/3600/24;
uint8_t h = t/3600;
uint8_t m = t%3600/60;
uint8_t s = t%60;
xprintf("uptime: %02u %02u:%02u:%02u\n", d, h, m, s);
#if 0
xprintf("LINK0: %s\r\n", get_link(RN42_LINK0));
xprintf("LINK1: %s\r\n", get_link(RN42_LINK1));
xprintf("LINK2: %s\r\n", get_link(RN42_LINK2));
xprintf("LINK3: %s\r\n", get_link(RN42_LINK3));
#endif
return true;
case KC_B:
// battery monitor
t = timer_read32()/1000;
b = battery_voltage();
xprintf("BAT: %umV\t", b);
xprintf("%02u:", t/3600);
xprintf("%02u:", t%3600/60);
//.........这里部分代码省略.........
示例7: install
// install installs the library, package, or binary associated with dir,
// which is relative to $GOROOT/src.
static void
install(char *dir)
{
char *name, *p, *elem, *prefix, *exe;
bool islib, ispkg, isgo, stale;
Buf b, b1, path;
Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t;
int i, j, k, n, doclean, targ;
if(vflag) {
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
xprintf("%s (%s/%s)\n", dir, goos, goarch);
else
xprintf("%s\n", dir);
}
binit(&b);
binit(&b1);
binit(&path);
vinit(&compile);
vinit(&files);
vinit(&link);
vinit(&go);
vinit(&missing);
vinit(&clean);
vinit(&lib);
vinit(&extra);
// path = full path to dir.
bpathf(&path, "%s/src/%s", goroot, dir);
name = lastelem(dir);
// For misc/prof, copy into the tool directory and we're done.
if(hasprefix(dir, "misc/")) {
copy(bpathf(&b, "%s/%s", tooldir, name),
bpathf(&b1, "%s/misc/%s", goroot, name), 1);
goto out;
}
// For release, cmd/prof and cmd/cov are not included.
if((streq(dir, "cmd/cov") || streq(dir, "cmd/prof")) && !isdir(bstr(&path))) {
if(vflag > 1)
xprintf("skipping %s - does not exist\n", dir);
goto out;
}
// set up gcc command line on first run.
if(gccargs.len == 0) {
xgetenv(&b, "CC");
if(b.len == 0)
bprintf(&b, "gcc");
splitfields(&gccargs, bstr(&b));
for(i=0; i<nelem(proto_gccargs); i++)
vadd(&gccargs, proto_gccargs[i]);
if(xstrstr(bstr(&b), "clang") != nil) {
vadd(&gccargs, "-Wno-dangling-else");
vadd(&gccargs, "-Wno-unused-value");
}
}
islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
ispkg = hasprefix(dir, "pkg");
isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo");
exe = "";
if(streq(gohostos, "windows"))
exe = ".exe";
// Start final link command line.
// Note: code below knows that link.p[targ] is the target.
if(islib) {
// C library.
vadd(&link, "ar");
vadd(&link, "rsc");
prefix = "";
if(!hasprefix(name, "lib"))
prefix = "lib";
targ = link.len;
vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohostos, gohostarch, prefix, name));
} else if(ispkg) {
// Go library (package).
vadd(&link, bpathf(&b, "%s/pack", tooldir));
vadd(&link, "grc");
p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
*xstrrchr(p, '/') = '\0';
xmkdirall(p);
targ = link.len;
vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4));
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
// Go command.
vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar));
vadd(&link, "-o");
elem = name;
if(streq(elem, "go"))
elem = "go_bootstrap";
targ = link.len;
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, elem, exe));
//.........这里部分代码省略.........
示例8: xml_attr
void xml_attr(const char *name, const char *val)
{
xprintf(" %s=\"", name);
xqputs(val);
xputs("\"");
}
示例9: xml_attr_int
void xml_attr_int(const char *name, largest_int val)
{
xprintf(" %s=\"%lld\"", name, val);
}
示例10: xml_qtag
void xml_qtag(const char *tag)
{
xprintf("<%s/>", tag);
}
示例11: xml_pop
void xml_pop(void)
{
xprintf("</%s>", pop_tag());
}
示例12: xml_tag_start
void xml_tag_start(const char *tag)
{
push_tag(tag);
xprintf("<%s", tag);
}
示例13: doc_end
static bool doc_end(struct urf_context *ctx)
{
return xprintf(ctx, "%%%%EOF\n");
}
示例14: xmpp_iq_sponsor_info_updated_cb
void xmpp_iq_sponsor_info_updated_cb(const char *msg_id,
const char *msg,
void *args)
{
/* Answer:
<iq from='[email protected]/xxx' type='get'>
<query xmlns='urn:cryonline:k01'>
<sponsor_info_updated sponsor_id='0' sponsor_points='864'
total_sponsor_points='2064' next_unlock_item='smg07_shop'>
<unlocked_items>
<item name='xxx' .../>
</unlocked_items>
</sponsor_info_updated>
</query>
</iq>
*/
char *data = wf_get_query_content(msg);
if (data == NULL)
return;
unsigned sponsor_id = get_info_int(data, "sponsor_id='", "'", NULL);
unsigned points = get_info_int(data, "sponsor_points='", "'", NULL);
unsigned total = get_info_int(data, "total_sponsor_points='", "'", NULL);
char *next_item = get_info(data, "next_unlock_item='", "'", NULL);
char *unlocked_items =
get_info(data, "<unlocked_items>", "</unlocked_items>", NULL);
if (unlocked_items != NULL)
{
const char *m = unlocked_items;
while ((m = strstr(m, "<item")) != NULL)
{
char *item = get_info(m, "<item", "/>", NULL);
char *item_name = get_info(item, "name='", "'", NULL);
xprintf("%s: %s",
LANG(notif_unlock_item),
item_name);
free(item_name);
free(item);
++m;
}
}
const char *sponsor = NULL;
switch (sponsor_id)
{
case 0:
sponsor = LANG(console_sponsor_weapon);
break;
case 1:
sponsor = LANG(console_sponsor_outfit);
break;
case 2:
sponsor = LANG(console_sponsor_equipment);
break;
default:
break;
}
if (sponsor != NULL && sponsor[0])
{
xprintf("%s: %u (+%u) - %s %s",
sponsor,
total,
points,
LANG(notif_unlocking),
next_item);
}
else
{
xprintf("%s: %u (+%u) - %s",
sponsor,
total,
points,
LANG(notif_unlocking_done));
}
free(unlocked_items);
free(next_item);
free(data);
}
示例15: mc_init
void mc_init(void)
{
xprintf("[%02u]: mc_init\n", corenum());
}