Error invalid suffix x on integer constant

Исправить ошибку "invalid suffix x on integer constant" C (СИ) Решение и ответ на вопрос 663774
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
#include <stdio.h>
 #include <math.h>
 
 int n;
 void sisestamine (int *ym, int *H, int *C, int *a)
 {
 printf("Sisesta funktsiooni piirv22rtus YM|n");
 scanf("%d", ym);
 printf("Sisesta sammu v22rtus Hn");
 scanf("%d", H);
 printf("Sisesta sammu koefitsent Cn");
 scanf("%d", C);
 printf("Sisesta x algv22rtusn");
 scanf("%d", a);
 }
 void arvutamine (int a, int C, int H, int ym, int x[15], float y[15])
 {
 int i=0;
 x[0]=a;
 do 
 { 
     double perem = pow((2*pow((double)x[i],2)+3*x[i]+4),3)-7;
 y[i]=(2*x[i]+1)/pow(perem,1/2);
 
 x[i+1]=(x[i]+C^i*H);
 i++;
 n=i;}
 while (i<15 && y[i-1]<=ym);
 }
 void v2ljastus (int x[15], float y[15])
 {
 int i;
 printf("X|Yn");
 for(i=0;i<=n-1;i++)
 {
 printf("%d|%fn", x[i], y[i]);
 }
 } 
 int main(void)
 {
 int i,a; 
 int x[15];
 float y[15];
 int ym, H, C;
 sisestamine (&ym,&H,&C,&a);
 arvutamine (a,C,H,ym,x,y);
 v2ljastus (x,y);
 printf("Vajuta enter v2ljumiseks!n");
 getchar();
 return 0;
 }

I am getiing the mentioned error for the following code:

#include "iostream"

#include <stdint.h>
#define CONTINUE 0x00
#define END 0x80
#define POWER7 0x

int main(){
        uint8_t *s = new uint8_t[ 10 ];
        int res = 0;
        int t = 2;
        res=t & POWER7;
        s [ 0]= ( t >POWER7 ? CONTINUE : END ) | res ;
        return 0;
}

This code was working fine, but after doing some modification, am geting the error.As I am new in c++, so quite unable to understand the error.

Error:

smple.cpp:11:10: error: invalid suffix "x" on integer constant
smple.cpp:12:15: error: invalid suffix "x" on integer constan

t

asked Mar 23, 2014 at 20:35

Sigcont's user avatar

2

You are using incorrect numeric literal

#define POWER7 0x

in statements

   res=t & POWER7;
    s [ 0]= ( t >POWER7 ? CONTINUE : END ) | res ;

According to the C++ Standard hexadecimal integer literal is defined the following way:

hexadecimal-literal:
0x hexadecimal-digit
0X hexadecimal-digit
hexadecimal-literal hexadecimal-digit

that is after 0x or 0X there must be at least one hexadecimal digit.

answered Mar 23, 2014 at 20:36

Vlad from Moscow's user avatar

Vlad from MoscowVlad from Moscow

287k23 gold badges179 silver badges323 bronze badges

3

  • Forum
  • Beginners
  • invalid suffix «x» on integer constant

invalid suffix «x» on integer constant

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
   double x, y;
   cin >> x;
   y = (sqrt(pow(x, 4) + 3)) / (abs(pow(x, 2) + 5)) + 4x;
   cout << y ;
   return 0;
}

I’m getting an error: invalid suffix «x» on integer constant, on row 9. How to fix it?

Write 4 * x if that is what you mean.

No, I meant x^4, but it doesn’t work, if I write like that

The ^ symbol is the exclusive or symbol, not the power symbol. You need to use pow() like the other areas in this calculation

x^4 mean what do you want?

I meant x*x*x*x, but this way it still doesn’t work. It gives me the same error: invalid suffix «x» on integer constant on row 9.

Just use pow() with the appropriate arguments. It’s already there in the code, just copy + paste it as required.

Or simply put x*x*x*x if you like.

Last edited on

Topic archived. No new replies allowed.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Open

amineejaam opened this issue

May 5, 2019

· 5 comments

Comments

@amineejaam

There is something wrong when I run make to build it
Here is the detail, could someone tell me how to solve this problem? Thank you!

/Users/cp0/riscv-tests/isa/../env/v/vm.c: In function 'coherence_torture':
<command-line>: error: invalid suffix "x" on integer constant
/Users/cp0/riscv-tests/isa/../env/v/vm.c:197:25: note: in expansion of macro 'ENTROPY'
   unsigned int random = ENTROPY;
/Users/cp0/riscv-tests/isa/../env/v/vm.c: In function 'vm_boot':
<command-line>: error: invalid suffix "x" on integer constant
/Users/cp0/riscv-tests/isa/../env/v/vm.c:212:25: note: in expansion of macro 'ENTROPY'
   unsigned int random = ENTROPY;
make[1]: *** [rv32ui-v-simple] Error 1
make: *** [isa] Error 2

@CwbhX

I have the same issue trying to build on Mac OS 10.14.5 :/
Can’t immediately see why this is occurring

@amineejaam what OS are you on, just wondering

@aswaterman

@CwbhX

@aswaterman I’m pretty busy at the moment, but thanks for pointing out the root cause. I’ll see if I can get it working under Mac OS and then test it in a VM when I get a moment.

@aswaterman

@dylanmc

I had this error just now (macOS 10.14), and thanks to this issue learned that the build is failing because macOS no longer has md5sum installed by default.

fixed my build on this platform. So maybe the fix is to check for it in autoconf (which is beyond me) and report this suggestion on macOS if it’s not found.

Задали задание, не понимаю почему пишет invalid suffix x on integer constant .
Спасибо большое!

#include <stdio.h>
#include <math.h>
 
int n;
void sisestamine (int *ym, int *H, int *C, int *a)
{
printf("Sisesta funktsiooni piirv22rtus YM|n");
scanf("%d", ym);
printf("Sisesta sammu v22rtus Hn");
scanf("%d", H);
printf("Sisesta sammu koefitsent Cn");
scanf("%d", C);
printf("Sisesta x algv22rtusn");
scanf("%d", a);
}
void arvutamine (int a, int C, int H, int ym, int x[15], float y[15])
{
int i=0;
x[0]=a;
       do 
             {      
                   y[i]=((2x[i]+1)/sqrt(2x[i]^2+3*x[i]+4)^3-7);
                     
                     x[i+1]=(x[i]+C^i*H);
                     i++;
                     n=i;}
       while (i<15 && y[i-1]<=ym);
                     }
void v2ljastus (int x[15], float y[15])
{
int i;
printf("X|Yn");
for(i=0;i<=n-1;i++)
{
                    printf("%d|%fn", x[i], y[i]);
                    }
                    } 
int main(void)
{
int i,a;                
int x[15];
float y[15];
int ym, H, C;
sisestamine (&ym,&H,&C,&a);
arvutamine (a,C,H,ym,x,y);
v2ljastus (x,y);
    printf("Vajuta enter v2ljumiseks!n");
    getchar();
    return 0;
}

Я получаю упомянутую ошибку для следующего кода:

#include "iostream"
#include <stdint.h>
#define CONTINUE 0x00
#define END 0x80
#define POWER7 0x

int main(){
uint8_t *s = new uint8_t[ 10 ];
int res = 0;
int t = 2;
res=t & POWER7;
s [ 0]= ( t >POWER7 ? CONTINUE : END ) | res ;
return 0;
}

Этот код работал нормально, но после внесения некоторых изменений я получаю сообщение об ошибке. Я новичок в c ++, поэтому совершенно не могу понять эту ошибку.

Ошибка:

smple.cpp:11:10: error: invalid suffix "x" on integer constant
smple.cpp:12:15: error: invalid suffix "x" on integer constan

T

-7

Решение

Вы используете неверный числовой литерал

#define POWER7 0x

в заявлениях

   res=t & POWER7;
s [ 0]= ( t >POWER7 ? CONTINUE : END ) | res ;

Согласно стандарту C ++ шестнадцатеричный целочисленный литерал определяется следующим образом:

hexadecimal-literal:
0x hexadecimal-digit
0X hexadecimal-digit
hexadecimal-literal hexadecimal-digit

то есть после 0x или 0X должна быть хотя бы одна шестнадцатеричная цифра.

3

Другие решения

Других решений пока нет …


Description


keith.rollin



2001-07-30 14:56:00 UTC

I am getting apparently incorrect "invalid suffix on integer constant" errors.  I don't see this myself because I don't have gcc 3.0, but someone I work with does, and I'm able to reproduce the problem with CodeSourcery's Online Test Compilation.

Release:
gcc 3.0

How-To-Repeat:
Go to  CodeSourcery's Online Test Compilation (<http://www.codesourcery.com/gcc-compile.shtml>). Enter the following into the big text box:

int a[0x00E-0x00A];

Hit "compile with  gcc".  You should get the error message.


Comment 1


keith.rollin



2001-07-30 14:56:00 UTC

Fix:
Add spaces around the minus sign.


Comment 2


Alexandre Oliva



2001-07-30 20:27:41 UTC

State-Changed-From-To: open->closed
State-Changed-Why: Strange as it may seem, the behavior is correct, and mandated by the C Standard.  0x00E-0x00A is a single preprocessor token, of type pp-number, and it must become a single compiler token, but it can't.  The gotcha is the `E-' sequence, that makes it seem like the exponent notation of floating-point constants.


Comment 3


Sandip



2003-12-09 13:02:54 UTC

Hi 
I am faching the same bug during compileation of module(Linux Kernel Verson
2.4.20-8). Please explane me about the fix "Add spaces around the minus sign."
 Where to add spaces and  around which minus sign?

Thanks and regards,
Sandip


Comment 4


Zack Weinberg



2003-12-09 18:18:59 UTC

int a[0x00E - 0x00A];


Comment 5


The gcc-bugs mailing list



2003-12-14 06:15:20 UTC

Not a bug...


Comment 6


The gcc-bugs mailing list



2003-12-14 06:16:17 UTC

So should be resolved-invalid


Comment 7


Andrew Pinski



2009-12-18 01:23:28 UTC

*** Bug 42421 has been marked as a duplicate of this bug. ***


Comment 8


Andrew Pinski



2009-12-18 01:24:00 UTC

*** Bug 11494 has been marked as a duplicate of this bug. ***


Comment 9


Andrew Pinski



2009-12-18 01:24:34 UTC

*** Bug 32805 has been marked as a duplicate of this bug. ***


Comment 10


Andrew Pinski



2011-01-30 02:47:56 UTC

*** Bug 47539 has been marked as a duplicate of this bug. ***


Comment 11


Andreas Schwab



2012-09-15 12:02:04 UTC

*** Bug 54587 has been marked as a duplicate of this bug. ***


Comment 12


Andrew Pinski



2014-09-22 05:13:03 UTC

*** Bug 63324 has been marked as a duplicate of this bug. ***


Comment 13


Andrew Pinski



2014-09-22 05:13:15 UTC

*** Bug 44272 has been marked as a duplicate of this bug. ***


Comment 14


Zack Weinberg



2018-04-11 13:40:08 UTC

I think we should reopen this bug and treat it as a request to improve the diagnostics.

GCC is correct to reject tokens of the form "0x000E-0x0001", but the accumulation of duplicate bug reports suggests that we could do a better job of explaining what is wrong.  Proposal: whenever we are about to issue the "invalid suffix on (integer/floating) constant" error, if the first character of the "invalid suffix" is + or -, we say instead something like

    error: invalid numeric constant "<entire pp-number token>"
    note: ('+'/'-') after ('e'/'p'/'E'/'P') continues a pp-number
    note: to perform (addition/subtraction), put a space before the ('+'/'-')

Printing the entire pp-number token instead of just the "suffix", mentioning the standardese term "pp-number", and calling the token an "invalid numeric constant" instead of an "invalid integer/floating constant" should clue people in to _why_ this apparently perverse tokenization is happening.


Comment 16


Andrew Pinski



2022-06-20 20:31:47 UTC

*** Bug 33547 has been marked as a duplicate of this bug. ***


Comment 17


Andrew Pinski



2022-06-20 20:31:56 UTC

*** Bug 45184 has been marked as a duplicate of this bug. ***

  1. проблема такая:
    собираю робота по проекту https://github.com/beetle-ringo/arduino

    но у меня дугой ик-приемник и пульт выдает сигнал с буквами: 93A5B961.
    я этот сигнал дописываю в подключаемый файл со списком сигналов:
    const long IR_COMMAND_BACKWARD_LEFT_CODES[] = { 68423, 2057, 9, 93A5B961 };
    при компиляции пишет:
    In file included from sketch_feb07a.ino:7:0:
    D:Program Files (x86)ArduinolibrariesIRremote/ir_command_codes.h:18:65: error: invalid suffix «A5B961» on integer constant
    const long IR_COMMAND_BACKWARD_LEFT_CODES[] = { 68423, 2057, 9, 93A5B961 };

    как заставить ардуино принять этот сигнал с пульта 93A5B961 ?

    спс

  2. Переведите из HEX в десятичное на калькуляторе

  3. спасибо, через 0х прописал

Понравилась статья? Поделить с друзьями:
  • Error invalid subscript selector maple
  • Error invalid storage class for function
  • Error invalid smb conf
  • Error invalid server check your port forwarding settings connection to lobby failed attempt number
  • Error invalid request squid