附近意外的标记语法错误“(”使用终端时, [英] Syntax error near unexpected token '(' when using terminal

查看:252
本文介绍了附近意外的标记语法错误“(”使用终端时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的平板电脑是一个砖砌CPUID,我有这个code,当我执行它通过终端Ubuntu的,它提供了以下错误:
5号线:附近意外的标记语法错误(
5号线:'诠释主要(无效)

我怎样才能解决这个问题呢?

 的#include<的libusb-1.0 / libusb.h>
#包括LT&;&stdio.h中GT;
#包括LT&;&stdint.h GT;INT主要(无效)
{
    unsigned char型数据[64];
    INT received_length;
    INT R = 1;
    libusb_context * CTX = NULL;
    libusb_device_handle * dev_handle = NULL;    libusb_init(安培; CTX);
    dev_handle = libusb_open_device_with_vid_pid(CTX,0x0955,0x7820);
    如果(dev_handle)
    {
        R = libusb_bulk_transfer(dev_handle,0x81表示,数据的sizeof(数据),放大器; received_length,10000);
        如果(R == 0)
        {
            如果(received_length == 8)
            {
               的printf(UID:为0x%08X 08X%\\ n,*((* uint32_t的)数据+ 1)*((* uint32_t的)数据+ 0));
            }
            其他
            {
                R = 1;
                的printf(错误:我们得到了8个字节,我们预计... \\ n个数据insetad%d字节,received_length);
            }
        }
        其他
        {
            的printf(错误:USB读取失败\\ n!);
        }
        libusb_release_interface(dev_handle,0);
    }
    其他
    {
        的printf(!错误:无法打开设备\\ n);
    }
    libusb_exit(CTX);
    返回ř;
}


解决方案

您需要编译程序并运行可执行文件。如果程序是 foo.c的,你编译:

 的gcc -o的foo.c富

然后你执行它:

  ./富

您不能直接运行C源文件 - C不是一个脚本语言

I am trying to get a cpuid for my tablet that is bricked and I have this code and when I execute it on ubuntu via terminal, it gives the following error: Line 5: Syntax error near unexpected token '(' Line 5: 'int main(void)'

how can I resolve this issue?

#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    unsigned char data[64];
    int received_length;
    int r = 1;
    libusb_context* ctx = NULL;
    libusb_device_handle* dev_handle = NULL;

    libusb_init(&ctx);
    dev_handle = libusb_open_device_with_vid_pid(ctx, 0x0955, 0x7820);
    if(dev_handle)
    {
        r = libusb_bulk_transfer(dev_handle, 0x81, data, sizeof(data), &received_length, 10000);
        if (r == 0)
        {
            if(received_length == 8)
            {
               printf("uid: 0x%08X%08X\n", *((uint32_t*)data+1), *((uint32_t*)data+0));
            }
            else
            {
                r = 1;
                printf("Error: We got %d bytes of data insetad of the 8 bytes we expected...\n", received_length);
            }
        }
        else
        {
            printf("Error: USB read failed!\n");
        }
        libusb_release_interface(dev_handle, 0);
    }
    else
    {
        printf("Error: Failed to open device!\n");
    }
    libusb_exit(ctx);
    return r;
}

解决方案

You need to compile the program and run the executable. If the program is in foo.c, you compile it with:

gcc foo.c -o foo

Then you execute it with:

./foo

You can't run a C source file directly -- C is not a scripting language.

这篇关于附近意外的标记语法错误“(”使用终端时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆