#define items when changed to int other variables are giving errors

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In my program there are some #define items, I want to change these values in my program,so I defined them as int now but there are other variables which take these as input and I am getting an error with them.

 

 ../src/wm8904_example.c: At top level:
 C:\Users\sriranjan\Documents\Atmel Studio\7.0\WM8904_EXAMPLE1\WM8904_EXAMPLE1\src\wm8904_example.c(154,11): error: variably modified 'linklist_write' at file scope
     lld_view1 linklist_write[TOTAL_BUFFERS];
               ^~~~~~~~~~~~~~
C:\Users\sriranjan\Documents\Atmel Studio\7.0\WM8904_EXAMPLE1\WM8904_EXAMPLE1\src\wm8904_example.c(155,11): error: variably modified 'linklist_read' at file scope
     lld_view1 linklist_read[TOTAL_BUFFERS];
               ^~~~~~~~~~~~~
C:\Users\sriranjan\Documents\Atmel Studio\7.0\WM8904_EXAMPLE1\WM8904_EXAMPLE1\src\wm8904_example.c(157,10): error: variably modified 'AudioBuffer' at file scope
     uint16_t AudioBuffer[TOTAL_BUFFERS * MICROBLOCK_LEN * (BITS_BY_SLOT/8

How shall I overcome these errors?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

youthreewire wrote:
How shall I overcome these errors?
By posting your source code showing the before/after conditions

 

But it seems to me that you may be trying to define an array dimension using a non const variable? Later C standards and C++ may support some dynamic dimensioinng but you can't do this in plain C

Last Edited: Tue. Sep 18, 2018 - 09:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, so I created two separate arrays of different size and the problem is solved. Yes dynamic dimensioning is now allowed as I understand.