+ Reply to Thread
Results 1 to 2 of 2

Thread: static_assert error "expression must have a constant value!"

  1. #1

    static_assert error "expression must have a constant value!"

    Hi All,

    I am using static_assert in my code and it does not compile. error is: "expression must have a constant value!"

    static_assert((nValue < 42), "This is not expected value. Value must be greater than or equal to 42") ;

    Thanks in advance.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    You are using non constant variable which causes the issue. Follow below pattern:

    Example:

    Code:
    #define INTEGER_VALUE 40
    
    void UseStaticAssert()
    {
    	static_assert((INTEGER_VALUE >= 42), "This is not expected value. Value must be greater than or equal to 42") ;
    }

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts